simple code format

This commit is contained in:
Strong Liu 2011-08-04 00:04:43 +08:00
parent 99e184883a
commit 660a7cbef1
3 changed files with 40 additions and 58 deletions

View File

@ -1101,23 +1101,21 @@ public abstract class Dialect {
* @since 3.2 * @since 3.2
*/ */
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) { switch ( lockMode ) {
case PESSIMISTIC_FORCE_INCREMENT:
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode ); return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
} case PESSIMISTIC_WRITE:
else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
return new PessimisticWriteSelectLockingStrategy( lockable, lockMode ); return new PessimisticWriteSelectLockingStrategy( lockable, lockMode );
} case PESSIMISTIC_READ:
else if ( lockMode==LockMode.PESSIMISTIC_READ) {
return new PessimisticReadSelectLockingStrategy( lockable, lockMode ); return new PessimisticReadSelectLockingStrategy( lockable, lockMode );
} case OPTIMISTIC:
else if ( lockMode==LockMode.OPTIMISTIC) {
return new OptimisticLockingStrategy( lockable, lockMode ); return new OptimisticLockingStrategy( lockable, lockMode );
} case OPTIMISTIC_FORCE_INCREMENT:
else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode ); return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
} default:
return new SelectLockingStrategy( lockable, lockMode ); return new SelectLockingStrategy( lockable, lockMode );
} }
}
/** /**
* Given LockOptions (lockMode, timeout), determine the appropriate for update fragment to use. * Given LockOptions (lockMode, timeout), determine the appropriate for update fragment to use.
@ -1127,22 +1125,22 @@ public abstract class Dialect {
*/ */
public String getForUpdateString(LockOptions lockOptions) { public String getForUpdateString(LockOptions lockOptions) {
LockMode lockMode = lockOptions.getLockMode(); LockMode lockMode = lockOptions.getLockMode();
if ( lockMode==LockMode.UPGRADE) { return getForUpdateString( lockMode, lockOptions.getTimeOut() );
}
private String getForUpdateString(LockMode lockMode, int timeout){
switch ( lockMode ) {
case UPGRADE:
return getForUpdateString(); return getForUpdateString();
} case PESSIMISTIC_READ:
else if( lockMode==LockMode.PESSIMISTIC_READ ) { return getReadLockString( timeout );
return getReadLockString(lockOptions.getTimeOut()); case PESSIMISTIC_WRITE:
} return getWriteLockString( timeout );
else if( lockMode==LockMode.PESSIMISTIC_WRITE ) { case UPGRADE_NOWAIT:
return getWriteLockString(lockOptions.getTimeOut()); case FORCE:
} case PESSIMISTIC_FORCE_INCREMENT:
else if ( lockMode==LockMode.UPGRADE_NOWAIT ) {
return getForUpdateNowaitString(); return getForUpdateNowaitString();
} default:
else if ( lockMode==LockMode.FORCE || lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
return getForUpdateNowaitString();
}
else {
return ""; return "";
} }
} }
@ -1154,24 +1152,7 @@ public abstract class Dialect {
* @return The appropriate for update fragment. * @return The appropriate for update fragment.
*/ */
public String getForUpdateString(LockMode lockMode) { public String getForUpdateString(LockMode lockMode) {
if ( lockMode==LockMode.UPGRADE ) { return getForUpdateString( lockMode, LockOptions.WAIT_FOREVER );
return getForUpdateString();
}
else if( lockMode==LockMode.PESSIMISTIC_READ ) {
return getReadLockString(LockOptions.WAIT_FOREVER);
}
else if( lockMode==LockMode.PESSIMISTIC_WRITE ) {
return getWriteLockString(LockOptions.WAIT_FOREVER);
}
else if ( lockMode==LockMode.UPGRADE_NOWAIT ) {
return getForUpdateNowaitString();
}
else if ( lockMode==LockMode.FORCE || lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
return getForUpdateNowaitString();
}
else {
return "";
}
} }
/** /**

View File

@ -89,7 +89,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
@Override @Override
public final Boolean isUnsaved(Object id) { public final Boolean isUnsaved(Object id) {
LOG.trace("ID unsaved-value strategy NULL"); LOG.trace("ID unsaved-value strategy NULL");
return id==null ? Boolean.TRUE : Boolean.FALSE; return id==null;
} }
@Override @Override
public Serializable getDefaultValue(Object currentValue) { public Serializable getDefaultValue(Object currentValue) {
@ -137,7 +137,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
*/ */
public Boolean isUnsaved(Object id) { public Boolean isUnsaved(Object id) {
LOG.trace("ID unsaved-value: " + value); LOG.trace("ID unsaved-value: " + value);
return id==null || id.equals(value) ? Boolean.TRUE : Boolean.FALSE; return id==null || id.equals(value);
} }
public Serializable getDefaultValue(Object currentValue) { public Serializable getDefaultValue(Object currentValue) {

View File

@ -39,6 +39,7 @@ import org.jboss.jandex.Index;
import org.jboss.jandex.MethodInfo; import org.jboss.jandex.MethodInfo;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.binding.InheritanceType; import org.hibernate.metamodel.binding.InheritanceType;
import org.hibernate.metamodel.source.annotations.entity.EntityClass; import org.hibernate.metamodel.source.annotations.entity.EntityClass;
import org.hibernate.metamodel.source.annotations.entity.RootEntitySourceImpl; import org.hibernate.metamodel.source.annotations.entity.RootEntitySourceImpl;
@ -158,7 +159,7 @@ public class EntityHierarchyBuilder {
/** /**
* Finds the root entity starting at the entity given by {@code info}. The root entity is not the highest superclass * Finds the root entity starting at the entity given by {@code info}. The root entity is not the highest superclass
* in a java type sense, but the highest superclass which is also an entity (annotated w/ {@code @Index}. * in a java type sense, but the highest superclass which is also an entity (annotated w/ {@code @Entity}.
* *
* @param index the annotation repository * @param index the annotation repository
* @param info the class info representing an entity * @param info the class info representing an entity
@ -329,10 +330,10 @@ public class EntityHierarchyBuilder {
List<AnnotationInstance> idAnnotations = info.annotations().get( JPADotNames.ID ); List<AnnotationInstance> idAnnotations = info.annotations().get( JPADotNames.ID );
List<AnnotationInstance> embeddedIdAnnotations = info.annotations().get( JPADotNames.EMBEDDED_ID ); List<AnnotationInstance> embeddedIdAnnotations = info.annotations().get( JPADotNames.EMBEDDED_ID );
if ( embeddedIdAnnotations != null && !embeddedIdAnnotations.isEmpty() ) { if ( CollectionHelper.isNotEmpty( embeddedIdAnnotations ) ) {
accessTypeByEmbeddedIdPlacement = determineAccessTypeByIdPlacement( embeddedIdAnnotations ); accessTypeByEmbeddedIdPlacement = determineAccessTypeByIdPlacement( embeddedIdAnnotations );
} }
if ( idAnnotations != null && !idAnnotations.isEmpty() ) { if ( CollectionHelper.isNotEmpty( idAnnotations ) ) {
accessTypeByIdPlacement = determineAccessTypeByIdPlacement( idAnnotations ); accessTypeByIdPlacement = determineAccessTypeByIdPlacement( idAnnotations );
} }
} }