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,22 +1101,20 @@ 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 ) {
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode); case PESSIMISTIC_FORCE_INCREMENT:
} return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
else if ( lockMode==LockMode.PESSIMISTIC_WRITE) { case 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:
} return new OptimisticLockingStrategy( lockable, lockMode );
else if ( lockMode==LockMode.OPTIMISTIC) { case OPTIMISTIC_FORCE_INCREMENT:
return new OptimisticLockingStrategy( lockable, lockMode); return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
} default:
else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) { return new SelectLockingStrategy( lockable, lockMode );
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode); }
}
return new SelectLockingStrategy( lockable, lockMode );
} }
/** /**
@ -1126,27 +1124,27 @@ public abstract class Dialect {
* @return The appropriate for update fragment. * @return The appropriate for update fragment.
*/ */
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() );
return getForUpdateString();
}
else if( lockMode==LockMode.PESSIMISTIC_READ ) {
return getReadLockString(lockOptions.getTimeOut());
}
else if( lockMode==LockMode.PESSIMISTIC_WRITE ) {
return getWriteLockString(lockOptions.getTimeOut());
}
else if ( lockMode==LockMode.UPGRADE_NOWAIT ) {
return getForUpdateNowaitString();
}
else if ( lockMode==LockMode.FORCE || lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
return getForUpdateNowaitString();
}
else {
return "";
}
} }
private String getForUpdateString(LockMode lockMode, int timeout){
switch ( lockMode ) {
case UPGRADE:
return getForUpdateString();
case PESSIMISTIC_READ:
return getReadLockString( timeout );
case PESSIMISTIC_WRITE:
return getWriteLockString( timeout );
case UPGRADE_NOWAIT:
case FORCE:
case PESSIMISTIC_FORCE_INCREMENT:
return getForUpdateNowaitString();
default:
return "";
}
}
/** /**
* Given a lock mode, determine the appropriate for update fragment to use. * Given a lock mode, determine the appropriate for update fragment to use.
* *
@ -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 );
} }
} }