simple code format
This commit is contained in:
parent
99e184883a
commit
660a7cbef1
|
@ -1101,22 +1101,20 @@ public abstract class Dialect {
|
|||
* @since 3.2
|
||||
*/
|
||||
public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
|
||||
if ( lockMode==LockMode.PESSIMISTIC_FORCE_INCREMENT) {
|
||||
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode);
|
||||
}
|
||||
else if ( lockMode==LockMode.PESSIMISTIC_WRITE) {
|
||||
return new PessimisticWriteSelectLockingStrategy( lockable, lockMode);
|
||||
}
|
||||
else if ( lockMode==LockMode.PESSIMISTIC_READ) {
|
||||
return new PessimisticReadSelectLockingStrategy( lockable, lockMode);
|
||||
}
|
||||
else if ( lockMode==LockMode.OPTIMISTIC) {
|
||||
return new OptimisticLockingStrategy( lockable, lockMode);
|
||||
}
|
||||
else if ( lockMode==LockMode.OPTIMISTIC_FORCE_INCREMENT) {
|
||||
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode);
|
||||
}
|
||||
return new SelectLockingStrategy( lockable, lockMode );
|
||||
switch ( lockMode ) {
|
||||
case PESSIMISTIC_FORCE_INCREMENT:
|
||||
return new PessimisticForceIncrementLockingStrategy( lockable, lockMode );
|
||||
case PESSIMISTIC_WRITE:
|
||||
return new PessimisticWriteSelectLockingStrategy( lockable, lockMode );
|
||||
case PESSIMISTIC_READ:
|
||||
return new PessimisticReadSelectLockingStrategy( lockable, lockMode );
|
||||
case OPTIMISTIC:
|
||||
return new OptimisticLockingStrategy( lockable, lockMode );
|
||||
case OPTIMISTIC_FORCE_INCREMENT:
|
||||
return new OptimisticForceIncrementLockingStrategy( lockable, lockMode );
|
||||
default:
|
||||
return new SelectLockingStrategy( lockable, lockMode );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1126,27 +1124,27 @@ public abstract class Dialect {
|
|||
* @return The appropriate for update fragment.
|
||||
*/
|
||||
public String getForUpdateString(LockOptions lockOptions) {
|
||||
LockMode lockMode = lockOptions.getLockMode();
|
||||
if ( lockMode==LockMode.UPGRADE) {
|
||||
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 "";
|
||||
}
|
||||
LockMode lockMode = lockOptions.getLockMode();
|
||||
return getForUpdateString( lockMode, lockOptions.getTimeOut() );
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
|
@ -1154,24 +1152,7 @@ public abstract class Dialect {
|
|||
* @return The appropriate for update fragment.
|
||||
*/
|
||||
public String getForUpdateString(LockMode lockMode) {
|
||||
if ( lockMode==LockMode.UPGRADE ) {
|
||||
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 "";
|
||||
}
|
||||
return getForUpdateString( lockMode, LockOptions.WAIT_FOREVER );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -89,7 +89,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
|
|||
@Override
|
||||
public final Boolean isUnsaved(Object id) {
|
||||
LOG.trace("ID unsaved-value strategy NULL");
|
||||
return id==null ? Boolean.TRUE : Boolean.FALSE;
|
||||
return id==null;
|
||||
}
|
||||
@Override
|
||||
public Serializable getDefaultValue(Object currentValue) {
|
||||
|
@ -137,7 +137,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
|
|||
*/
|
||||
public Boolean isUnsaved(Object id) {
|
||||
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) {
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.jboss.jandex.Index;
|
|||
import org.jboss.jandex.MethodInfo;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
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
|
||||
* 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 info the class info representing an entity
|
||||
|
@ -329,10 +330,10 @@ public class EntityHierarchyBuilder {
|
|||
List<AnnotationInstance> idAnnotations = info.annotations().get( JPADotNames.ID );
|
||||
List<AnnotationInstance> embeddedIdAnnotations = info.annotations().get( JPADotNames.EMBEDDED_ID );
|
||||
|
||||
if ( embeddedIdAnnotations != null && !embeddedIdAnnotations.isEmpty() ) {
|
||||
if ( CollectionHelper.isNotEmpty( embeddedIdAnnotations ) ) {
|
||||
accessTypeByEmbeddedIdPlacement = determineAccessTypeByIdPlacement( embeddedIdAnnotations );
|
||||
}
|
||||
if ( idAnnotations != null && !idAnnotations.isEmpty() ) {
|
||||
if ( CollectionHelper.isNotEmpty( idAnnotations ) ) {
|
||||
accessTypeByIdPlacement = determineAccessTypeByIdPlacement( idAnnotations );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue