simple code refact

This commit is contained in:
Strong Liu 2011-08-15 14:55:06 +08:00
parent dc7feab061
commit 71adfabca8
4 changed files with 32 additions and 8 deletions

View File

@ -50,7 +50,7 @@ public class VersionValue implements UnsavedValueStrategy {
@Override
public final Boolean isUnsaved(Object version) {
LOG.trace("Version unsaved-value strategy NULL");
return version==null ? Boolean.TRUE : Boolean.FALSE;
return version==null;
}
@Override
public Object getDefaultValue(Object currentValue) {
@ -69,7 +69,7 @@ public class VersionValue implements UnsavedValueStrategy {
@Override
public final Boolean isUnsaved(Object version) {
LOG.trace("Version unsaved-value strategy UNDEFINED");
return version==null ? Boolean.TRUE : null;
return version==null;
}
@Override
public Object getDefaultValue(Object currentValue) {
@ -90,7 +90,7 @@ public class VersionValue implements UnsavedValueStrategy {
public final Boolean isUnsaved(Object version) throws MappingException {
LOG.trace("Version unsaved-value strategy NEGATIVE");
if (version==null) return Boolean.TRUE;
if (version instanceof Number) return ((Number)version).longValue() < 0l ? Boolean.TRUE : Boolean.FALSE;
if (version instanceof Number) return ((Number)version).longValue() < 0l;
throw new MappingException("unsaved-value NEGATIVE may only be used with short, int and long types");
}
@Override
@ -121,7 +121,7 @@ public class VersionValue implements UnsavedValueStrategy {
@Override
public Boolean isUnsaved(Object version) throws MappingException {
LOG.trace("Version unsaved-value: " + value);
return version==null || version.equals(value) ? Boolean.TRUE : Boolean.FALSE;
return version==null || version.equals(value);
}
@Override

View File

@ -84,7 +84,7 @@ public final class IdentifierGeneratorHelper {
if ( !rs.next() ) {
throw new HibernateException( "The database returned no natively generated identity value" );
}
final Serializable id = IdentifierGeneratorHelper.get( rs, type );
final Serializable id = get( rs, type );
LOG.debugf("Natively generated identity: %s", id);
return id;
}

View File

@ -42,14 +42,14 @@ public interface LazyInitializer {
public void initialize() throws HibernateException;
/**
* Retrieve the identifier value for the enity our owning proxy represents.
* Retrieve the identifier value for the entity our owning proxy represents.
*
* @return The identifier value.
*/
public Serializable getIdentifier();
/**
* Set the identifier value for the enity our owning proxy represents.
* Set the identifier value for the entity our owning proxy represents.
*
* @param id The identifier value.
*/
@ -93,7 +93,7 @@ public interface LazyInitializer {
*
* @throws HibernateException Indicates problem locating the target.
*/
public abstract Object getImplementation(SessionImplementor session) throws HibernateException;
public Object getImplementation(SessionImplementor session) throws HibernateException;
/**
* Initialize the proxy manually by injecting its target.

View File

@ -1,3 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.entity;
import javax.persistence.Embeddable;