HHH-5205 - Renamed BinderHelper.isDefault() to BinderHelper.isEmptyAnnotationValue() , because this describes better what the function does. Also renamed VersionTest to OptimisitcLockAnnotationTest to better describe what gets tested.
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20741 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
e14f58de29
commit
7419fc298d
|
@ -499,7 +499,7 @@ public class BinderHelper {
|
|||
// YUCK! but cannot think of a clean way to do this given the string-config based scheme
|
||||
params.put( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, mappings.getObjectNameNormalizer() );
|
||||
|
||||
if ( !isDefault( generatorName ) ) {
|
||||
if ( !isEmptyAnnotationValue( generatorName ) ) {
|
||||
//we have a named generator
|
||||
IdGenerator gen = mappings.getGenerator( generatorName, localGenerators );
|
||||
if ( gen == null ) {
|
||||
|
@ -526,7 +526,7 @@ public class BinderHelper {
|
|||
id.setIdentifierGeneratorProperties( params );
|
||||
}
|
||||
|
||||
public static boolean isDefault(String annotationString) {
|
||||
public static boolean isEmptyAnnotationValue(String annotationString) {
|
||||
return annotationString != null && annotationString.length() == 0;
|
||||
//equivalent to (but faster) ANNOTATION_STRING_DEFAULT.equals( annotationString );
|
||||
}
|
||||
|
@ -628,7 +628,7 @@ public class BinderHelper {
|
|||
}
|
||||
|
||||
private static void checkAnyMetaDefValidity(boolean mustHaveName, AnyMetaDef defAnn, XAnnotatedElement annotatedElement) {
|
||||
if ( mustHaveName && isDefault( defAnn.name() ) ) {
|
||||
if ( mustHaveName && isEmptyAnnotationValue( defAnn.name() ) ) {
|
||||
String name = XClass.class.isAssignableFrom( annotatedElement.getClass() ) ?
|
||||
( (XClass) annotatedElement ).getName() :
|
||||
( (XPackage) annotatedElement ).getName();
|
||||
|
@ -637,7 +637,7 @@ public class BinderHelper {
|
|||
}
|
||||
|
||||
private static void bindAnyMetaDef(AnyMetaDef defAnn, Mappings mappings) {
|
||||
if ( isDefault( defAnn.name() ) ) return; //don't map not named definitions
|
||||
if ( isEmptyAnnotationValue( defAnn.name() ) ) return; //don't map not named definitions
|
||||
log.info( "Binding Any Meta definition: {}", defAnn.name() );
|
||||
mappings.addAnyMetaDef( defAnn );
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class CopyIdentifierComponentSecondPass implements SecondPass {
|
|||
Map<String, Ejb3JoinColumn> columnByReferencedName = new HashMap<String, Ejb3JoinColumn>(joinColumns.length);
|
||||
for (Ejb3JoinColumn joinColumn : joinColumns) {
|
||||
final String referencedColumnName = joinColumn.getReferencedColumn();
|
||||
if ( referencedColumnName == null || BinderHelper.isDefault( referencedColumnName ) ) {
|
||||
if ( referencedColumnName == null || BinderHelper.isEmptyAnnotationValue( referencedColumnName ) ) {
|
||||
break;
|
||||
}
|
||||
//JPA 2 requires referencedColumnNames to be case insensitive
|
||||
|
|
|
@ -71,12 +71,12 @@ public class Ejb3DiscriminatorColumn extends Ejb3Column {
|
|||
}
|
||||
else if ( discAnn != null ) {
|
||||
discriminatorColumn.setImplicit( false );
|
||||
if ( !BinderHelper.isDefault( discAnn.columnDefinition() ) ) {
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( discAnn.columnDefinition() ) ) {
|
||||
discriminatorColumn.setSqlType(
|
||||
discAnn.columnDefinition()
|
||||
);
|
||||
}
|
||||
if ( !BinderHelper.isDefault( discAnn.name() ) ) {
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( discAnn.name() ) ) {
|
||||
discriminatorColumn.setLogicalColumnName( discAnn.name() );
|
||||
}
|
||||
discriminatorColumn.setNullable( false );
|
||||
|
|
|
@ -249,7 +249,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
|||
String suffixForDefaultColumnName,
|
||||
Mappings mappings) {
|
||||
if ( ann != null ) {
|
||||
if ( BinderHelper.isDefault( mappedBy ) ) {
|
||||
if ( BinderHelper.isEmptyAnnotationValue( mappedBy ) ) {
|
||||
throw new AnnotationException(
|
||||
"Illegal attempt to define a @JoinColumn with a mappedBy association: "
|
||||
+ BinderHelper.getRelativePath( propertyHolder, propertyName )
|
||||
|
@ -299,8 +299,8 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
|||
}
|
||||
else {
|
||||
setImplicit( false );
|
||||
if ( !BinderHelper.isDefault( annJoin.columnDefinition() ) ) setSqlType( annJoin.columnDefinition() );
|
||||
if ( !BinderHelper.isDefault( annJoin.name() ) ) setLogicalColumnName( annJoin.name() );
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( annJoin.columnDefinition() ) ) setSqlType( annJoin.columnDefinition() );
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( annJoin.name() ) ) setLogicalColumnName( annJoin.name() );
|
||||
setNullable( annJoin.nullable() );
|
||||
setUnique( annJoin.unique() );
|
||||
setInsertable( annJoin.insertable() );
|
||||
|
|
|
@ -88,8 +88,8 @@ public class IndexColumn extends Ejb3Column {
|
|||
Mappings mappings) {
|
||||
IndexColumn column;
|
||||
if ( ann != null ) {
|
||||
String sqlType = BinderHelper.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition();
|
||||
String name = BinderHelper.isDefault( ann.name() ) ? inferredData.getPropertyName() + "_ORDER" : ann.name();
|
||||
String sqlType = BinderHelper.isEmptyAnnotationValue( ann.columnDefinition() ) ? null : ann.columnDefinition();
|
||||
String name = BinderHelper.isEmptyAnnotationValue( ann.name() ) ? inferredData.getPropertyName() + "_ORDER" : ann.name();
|
||||
//TODO move it to a getter based system and remove the constructor
|
||||
// The JPA OrderColumn annotation defines no table element...
|
||||
// column = new IndexColumn(
|
||||
|
@ -120,8 +120,8 @@ public class IndexColumn extends Ejb3Column {
|
|||
Mappings mappings) {
|
||||
IndexColumn column;
|
||||
if ( ann != null ) {
|
||||
String sqlType = BinderHelper.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition();
|
||||
String name = BinderHelper.isDefault( ann.name() ) ? inferredData.getPropertyName() : ann.name();
|
||||
String sqlType = BinderHelper.isEmptyAnnotationValue( ann.columnDefinition() ) ? null : ann.columnDefinition();
|
||||
String name = BinderHelper.isEmptyAnnotationValue( ann.name() ) ? inferredData.getPropertyName() : ann.name();
|
||||
//TODO move it to a getter based system and remove the constructor
|
||||
column = new IndexColumn(
|
||||
false, sqlType, 0, 0, 0, name, ann.nullable(),
|
||||
|
|
|
@ -114,7 +114,7 @@ public class OneToOneSecondPass implements SecondPass {
|
|||
binder.setCascade( cascadeStrategy );
|
||||
binder.setAccessType( inferredData.getDefaultAccess() );
|
||||
Property prop = binder.makeProperty();
|
||||
if ( BinderHelper.isDefault( mappedBy ) ) {
|
||||
if ( BinderHelper.isEmptyAnnotationValue( mappedBy ) ) {
|
||||
/*
|
||||
* we need to check if the columns are in the right order
|
||||
* if not, then we need to create a many to one and formula
|
||||
|
@ -236,7 +236,7 @@ public class OneToOneSecondPass implements SecondPass {
|
|||
}
|
||||
ForeignKey fk = inferredData.getProperty().getAnnotation( ForeignKey.class );
|
||||
String fkName = fk != null ? fk.name() : "";
|
||||
if ( !BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName );
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) value.setForeignKeyName( fkName );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
package org.hibernate.cfg;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.cfg.annotations.SimpleValueBinder;
|
||||
|
||||
/**
|
||||
* @author Sharath Reddy
|
||||
*
|
||||
*/
|
||||
public class SetSimpleValueTypeSecondPass implements SecondPass {
|
||||
|
||||
|
@ -42,5 +42,4 @@ public class SetSimpleValueTypeSecondPass implements SecondPass {
|
|||
public void doSecondPass(Map persistentClasses) throws MappingException {
|
||||
binder.fillSimpleValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ public abstract class CollectionBinder {
|
|||
|
||||
public void setSqlOrderBy(OrderBy orderByAnn) {
|
||||
if ( orderByAnn != null ) {
|
||||
if ( !BinderHelper.isDefault( orderByAnn.clause() ) ) {
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( orderByAnn.clause() ) ) {
|
||||
orderBy = orderByAnn.clause();
|
||||
}
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ public abstract class CollectionBinder {
|
|||
}
|
||||
|
||||
//work on association
|
||||
boolean isMappedBy = !BinderHelper.isDefault( mappedBy );
|
||||
boolean isMappedBy = !BinderHelper.isEmptyAnnotationValue( mappedBy );
|
||||
|
||||
if (isMappedBy
|
||||
&& (property.isAnnotationPresent( JoinColumn.class )
|
||||
|
@ -672,7 +672,7 @@ public abstract class CollectionBinder {
|
|||
&& !reversePropertyInJoin
|
||||
&& oneToMany
|
||||
&& !this.isExplicitAssociationTable
|
||||
&& ( joinColumns[0].isImplicit() && !BinderHelper.isDefault( this.mappedBy ) //implicit @JoinColumn
|
||||
&& ( joinColumns[0].isImplicit() && !BinderHelper.isEmptyAnnotationValue( this.mappedBy ) //implicit @JoinColumn
|
||||
|| !fkJoinColumns[0].isImplicit() ) //this is an explicit @JoinColumn
|
||||
) {
|
||||
//this is a Foreign key
|
||||
|
@ -865,7 +865,7 @@ public abstract class CollectionBinder {
|
|||
}
|
||||
|
||||
private String getCondition(String cond, String name) {
|
||||
if ( BinderHelper.isDefault( cond ) ) {
|
||||
if ( BinderHelper.isEmptyAnnotationValue( cond ) ) {
|
||||
cond = mappings.getFilterDefinition( name ).getDefaultFilterCondition();
|
||||
if ( StringHelper.isEmpty( cond ) ) {
|
||||
throw new AnnotationException(
|
||||
|
@ -879,7 +879,7 @@ public abstract class CollectionBinder {
|
|||
|
||||
public void setCache(Cache cacheAnn) {
|
||||
if ( cacheAnn != null ) {
|
||||
cacheRegionName = BinderHelper.isDefault( cacheAnn.region() ) ? null : cacheAnn.region();
|
||||
cacheRegionName = BinderHelper.isEmptyAnnotationValue( cacheAnn.region() ) ? null : cacheAnn.region();
|
||||
cacheConcurrencyStrategy = EntityBinder.getCacheConcurrencyStrategy( cacheAnn.usage() );
|
||||
}
|
||||
else {
|
||||
|
@ -1123,7 +1123,7 @@ public abstract class CollectionBinder {
|
|||
collValue.setKey( key );
|
||||
ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null;
|
||||
String fkName = fk != null ? fk.name() : "";
|
||||
if ( !BinderHelper.isDefault( fkName ) ) key.setForeignKeyName( fkName );
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) key.setForeignKeyName( fkName );
|
||||
return key;
|
||||
}
|
||||
|
||||
|
@ -1188,7 +1188,7 @@ public abstract class CollectionBinder {
|
|||
}
|
||||
}
|
||||
|
||||
boolean mappedBy = !BinderHelper.isDefault( joinColumns[0].getMappedBy() );
|
||||
boolean mappedBy = !BinderHelper.isEmptyAnnotationValue( joinColumns[0].getMappedBy() );
|
||||
if ( mappedBy ) {
|
||||
if ( !isCollectionOfEntities ) {
|
||||
StringBuilder error = new StringBuilder( 80 )
|
||||
|
@ -1281,7 +1281,7 @@ public abstract class CollectionBinder {
|
|||
}
|
||||
ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null;
|
||||
String fkName = fk != null ? fk.inverseName() : "";
|
||||
if ( !BinderHelper.isDefault( fkName ) ) element.setForeignKeyName( fkName );
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) element.setForeignKeyName( fkName );
|
||||
}
|
||||
else if ( anyAnn != null ) {
|
||||
//@ManyToAny
|
||||
|
|
|
@ -170,7 +170,7 @@ public class EntityBinder {
|
|||
|
||||
private void bindEjb3Annotation(Entity ejb3Ann) {
|
||||
if ( ejb3Ann == null ) throw new AssertionFailure( "@Entity should always be not null" );
|
||||
if ( BinderHelper.isDefault( ejb3Ann.name() ) ) {
|
||||
if ( BinderHelper.isEmptyAnnotationValue( ejb3Ann.name() ) ) {
|
||||
name = StringHelper.unqualify( annotatedClass.getName() );
|
||||
}
|
||||
else {
|
||||
|
@ -243,7 +243,7 @@ public class EntityBinder {
|
|||
}
|
||||
else {
|
||||
org.hibernate.annotations.Entity entityAnn = annotatedClass.getAnnotation( org.hibernate.annotations.Entity.class );
|
||||
if ( entityAnn != null && !BinderHelper.isDefault( entityAnn.persister() ) ) {
|
||||
if ( entityAnn != null && !BinderHelper.isEmptyAnnotationValue( entityAnn.persister() ) ) {
|
||||
try {
|
||||
persister = ReflectHelper.classForName( entityAnn.persister() );
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ public class EntityBinder {
|
|||
for ( Map.Entry<String, String> filter : filters.entrySet() ) {
|
||||
String filterName = filter.getKey();
|
||||
String cond = filter.getValue();
|
||||
if ( BinderHelper.isDefault( cond ) ) {
|
||||
if ( BinderHelper.isEmptyAnnotationValue( cond ) ) {
|
||||
FilterDefinition definition = mappings.getFilterDefinition( filterName );
|
||||
cond = definition == null ? null : definition.getDefaultFilterCondition();
|
||||
if ( StringHelper.isEmpty( cond ) ) {
|
||||
|
@ -606,7 +606,7 @@ public class EntityBinder {
|
|||
|
||||
private void setFKNameIfDefined(Join join) {
|
||||
org.hibernate.annotations.Table matchingTable = findMatchingComplimentTableAnnotation( join );
|
||||
if ( matchingTable != null && !BinderHelper.isDefault( matchingTable.foreignKey().name() ) ) {
|
||||
if ( matchingTable != null && !BinderHelper.isEmptyAnnotationValue( matchingTable.foreignKey().name() ) ) {
|
||||
( (SimpleValue) join.getKey() ).setForeignKeyName( matchingTable.foreignKey().name() );
|
||||
}
|
||||
}
|
||||
|
@ -740,19 +740,19 @@ public class EntityBinder {
|
|||
join.setSequentialSelect( FetchMode.JOIN != matchingTable.fetch() );
|
||||
join.setInverse( matchingTable.inverse() );
|
||||
join.setOptional( matchingTable.optional() );
|
||||
if ( !BinderHelper.isDefault( matchingTable.sqlInsert().sql() ) ) {
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( matchingTable.sqlInsert().sql() ) ) {
|
||||
join.setCustomSQLInsert( matchingTable.sqlInsert().sql().trim(),
|
||||
matchingTable.sqlInsert().callable(),
|
||||
ExecuteUpdateResultCheckStyle.parse( matchingTable.sqlInsert().check().toString().toLowerCase() )
|
||||
);
|
||||
}
|
||||
if ( !BinderHelper.isDefault( matchingTable.sqlUpdate().sql() ) ) {
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( matchingTable.sqlUpdate().sql() ) ) {
|
||||
join.setCustomSQLUpdate( matchingTable.sqlUpdate().sql().trim(),
|
||||
matchingTable.sqlUpdate().callable(),
|
||||
ExecuteUpdateResultCheckStyle.parse( matchingTable.sqlUpdate().check().toString().toLowerCase() )
|
||||
);
|
||||
}
|
||||
if ( !BinderHelper.isDefault( matchingTable.sqlDelete().sql() ) ) {
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( matchingTable.sqlDelete().sql() ) ) {
|
||||
join.setCustomSQLDelete( matchingTable.sqlDelete().sql().trim(),
|
||||
matchingTable.sqlDelete().callable(),
|
||||
ExecuteUpdateResultCheckStyle.parse( matchingTable.sqlDelete().check().toString().toLowerCase() )
|
||||
|
@ -782,7 +782,7 @@ public class EntityBinder {
|
|||
|
||||
public void setCache(Cache cacheAnn) {
|
||||
if ( cacheAnn != null ) {
|
||||
cacheRegion = BinderHelper.isDefault( cacheAnn.region() ) ?
|
||||
cacheRegion = BinderHelper.isEmptyAnnotationValue( cacheAnn.region() ) ?
|
||||
null :
|
||||
cacheAnn.region();
|
||||
cacheConcurrentStrategy = getCacheConcurrencyStrategy( cacheAnn.usage() );
|
||||
|
@ -853,7 +853,7 @@ public class EntityBinder {
|
|||
"@org.hibernate.annotations.Table references an unknown table: " + appliedTable
|
||||
);
|
||||
}
|
||||
if ( !BinderHelper.isDefault( table.comment() ) ) hibTable.setComment( table.comment() );
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( table.comment() ) ) hibTable.setComment( table.comment() );
|
||||
TableBinder.addIndexes( hibTable, table.indexes(), mappings );
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public class IdBagBinder extends BagBinder {
|
|||
simpleValue.setTable( table );
|
||||
simpleValue.setColumns( idColumns );
|
||||
Type typeAnn = collectionIdAnn.type();
|
||||
if ( typeAnn != null && !BinderHelper.isDefault( typeAnn.type() ) ) {
|
||||
if ( typeAnn != null && !BinderHelper.isEmptyAnnotationValue( typeAnn.type() ) ) {
|
||||
simpleValue.setExplicitType( typeAnn );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -285,12 +285,12 @@ public class MapBinder extends CollectionBinder {
|
|||
//the algorithm generally does not apply for map key anyway
|
||||
MapKey mapKeyAnn = property.getAnnotation( org.hibernate.annotations.MapKey.class );
|
||||
elementBinder.setKey(true);
|
||||
if (mapKeyAnn != null && ! BinderHelper.isDefault( mapKeyAnn.type().type() ) ) {
|
||||
if (mapKeyAnn != null && ! BinderHelper.isEmptyAnnotationValue( mapKeyAnn.type().type() ) ) {
|
||||
elementBinder.setExplicitType( mapKeyAnn.type() );
|
||||
}
|
||||
else {
|
||||
MapKeyType mapKeyTypeAnnotation = property.getAnnotation( MapKeyType.class );
|
||||
if ( mapKeyTypeAnnotation != null && ! BinderHelper.isDefault( mapKeyTypeAnnotation.value().type() ) ) {
|
||||
if ( mapKeyTypeAnnotation != null && ! BinderHelper.isEmptyAnnotationValue( mapKeyTypeAnnotation.value().type() ) ) {
|
||||
elementBinder.setExplicitType( mapKeyTypeAnnotation.value() );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -59,7 +59,7 @@ public abstract class QueryBinder {
|
|||
|
||||
public static void bindQuery(NamedQuery queryAnn, Mappings mappings, boolean isDefault) {
|
||||
if ( queryAnn == null ) return;
|
||||
if ( BinderHelper.isDefault( queryAnn.name() ) ) {
|
||||
if ( BinderHelper.isEmptyAnnotationValue( queryAnn.name() ) ) {
|
||||
throw new AnnotationException( "A named query must have a name when used in class or package level" );
|
||||
}
|
||||
//EJBQL Query
|
||||
|
@ -90,14 +90,14 @@ public abstract class QueryBinder {
|
|||
public static void bindNativeQuery(NamedNativeQuery queryAnn, Mappings mappings, boolean isDefault) {
|
||||
if ( queryAnn == null ) return;
|
||||
//ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() );
|
||||
if ( BinderHelper.isDefault( queryAnn.name() ) ) {
|
||||
if ( BinderHelper.isEmptyAnnotationValue( queryAnn.name() ) ) {
|
||||
throw new AnnotationException( "A named query must have a name when used in class or package level" );
|
||||
}
|
||||
NamedSQLQueryDefinition query;
|
||||
String resultSetMapping = queryAnn.resultSetMapping();
|
||||
QueryHint[] hints = queryAnn.hints();
|
||||
String queryName = queryAnn.query();
|
||||
if ( !BinderHelper.isDefault( resultSetMapping ) ) {
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( resultSetMapping ) ) {
|
||||
//sql result set usage
|
||||
query = new NamedSQLQueryDefinition(
|
||||
queryName,
|
||||
|
@ -151,25 +151,25 @@ public abstract class QueryBinder {
|
|||
public static void bindNativeQuery(org.hibernate.annotations.NamedNativeQuery queryAnn, Mappings mappings) {
|
||||
if ( queryAnn == null ) return;
|
||||
//ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() );
|
||||
if ( BinderHelper.isDefault( queryAnn.name() ) ) {
|
||||
if ( BinderHelper.isEmptyAnnotationValue( queryAnn.name() ) ) {
|
||||
throw new AnnotationException( "A named query must have a name when used in class or package level" );
|
||||
}
|
||||
NamedSQLQueryDefinition query;
|
||||
String resultSetMapping = queryAnn.resultSetMapping();
|
||||
if ( !BinderHelper.isDefault( resultSetMapping ) ) {
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( resultSetMapping ) ) {
|
||||
//sql result set usage
|
||||
query = new NamedSQLQueryDefinition(
|
||||
queryAnn.query(),
|
||||
resultSetMapping,
|
||||
null,
|
||||
queryAnn.cacheable(),
|
||||
BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
|
||||
BinderHelper.isEmptyAnnotationValue( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
|
||||
queryAnn.timeout() < 0 ? null : queryAnn.timeout(),
|
||||
queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(),
|
||||
getFlushMode( queryAnn.flushMode() ),
|
||||
getCacheMode( queryAnn.cacheMode() ),
|
||||
queryAnn.readOnly(),
|
||||
BinderHelper.isDefault( queryAnn.comment() ) ? null : queryAnn.comment(),
|
||||
BinderHelper.isEmptyAnnotationValue( queryAnn.comment() ) ? null : queryAnn.comment(),
|
||||
null,
|
||||
queryAnn.callable()
|
||||
);
|
||||
|
@ -184,13 +184,13 @@ public abstract class QueryBinder {
|
|||
new NativeSQLQueryReturn[] { entityQueryReturn },
|
||||
null,
|
||||
queryAnn.cacheable(),
|
||||
BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
|
||||
BinderHelper.isEmptyAnnotationValue( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
|
||||
queryAnn.timeout() < 0 ? null : queryAnn.timeout(),
|
||||
queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(),
|
||||
getFlushMode( queryAnn.flushMode() ),
|
||||
getCacheMode( queryAnn.cacheMode() ),
|
||||
queryAnn.readOnly(),
|
||||
BinderHelper.isDefault( queryAnn.comment() ) ? null : queryAnn.comment(),
|
||||
BinderHelper.isEmptyAnnotationValue( queryAnn.comment() ) ? null : queryAnn.comment(),
|
||||
null,
|
||||
queryAnn.callable()
|
||||
);
|
||||
|
@ -227,7 +227,7 @@ public abstract class QueryBinder {
|
|||
|
||||
public static void bindQuery(org.hibernate.annotations.NamedQuery queryAnn, Mappings mappings) {
|
||||
if ( queryAnn == null ) return;
|
||||
if ( BinderHelper.isDefault( queryAnn.name() ) ) {
|
||||
if ( BinderHelper.isEmptyAnnotationValue( queryAnn.name() ) ) {
|
||||
throw new AnnotationException( "A named query must have a name when used in class or package level" );
|
||||
}
|
||||
|
||||
|
@ -237,13 +237,13 @@ public abstract class QueryBinder {
|
|||
NamedQueryDefinition query = new NamedQueryDefinition(
|
||||
queryAnn.query(),
|
||||
queryAnn.cacheable(),
|
||||
BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
|
||||
BinderHelper.isEmptyAnnotationValue( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
|
||||
queryAnn.timeout() < 0 ? null : queryAnn.timeout(),
|
||||
queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize(),
|
||||
flushMode,
|
||||
getCacheMode( queryAnn.cacheMode() ),
|
||||
queryAnn.readOnly(),
|
||||
BinderHelper.isDefault( queryAnn.comment() ) ? null : queryAnn.comment(),
|
||||
BinderHelper.isEmptyAnnotationValue( queryAnn.comment() ) ? null : queryAnn.comment(),
|
||||
null
|
||||
);
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ public class ResultsetMappingSecondPass implements QuerySecondPass {
|
|||
);
|
||||
}
|
||||
|
||||
if ( !BinderHelper.isDefault( entity.discriminatorColumn() ) ) {
|
||||
if ( !BinderHelper.isEmptyAnnotationValue( entity.discriminatorColumn() ) ) {
|
||||
final String quotingNormalizedName = mappings.getObjectNameNormalizer().normalizeIdentifierQuoting(
|
||||
entity.discriminatorColumn()
|
||||
);
|
||||
|
|
|
@ -213,8 +213,8 @@ public class TableBinder {
|
|||
Table denormalizedSuperTable,
|
||||
Mappings mappings,
|
||||
String subselect) {
|
||||
schema = BinderHelper.isDefault( schema ) ? mappings.getSchemaName() : schema;
|
||||
catalog = BinderHelper.isDefault( catalog ) ? mappings.getCatalogName() : catalog;
|
||||
schema = BinderHelper.isEmptyAnnotationValue( schema ) ? mappings.getSchemaName() : schema;
|
||||
catalog = BinderHelper.isEmptyAnnotationValue( catalog ) ? mappings.getCatalogName() : catalog;
|
||||
|
||||
String realTableName = mappings.getObjectNameNormalizer().normalizeDatabaseIdentifier(
|
||||
nameSource.getExplicitName(),
|
||||
|
@ -282,8 +282,8 @@ public class TableBinder {
|
|||
String constraints,
|
||||
Table denormalizedSuperTable,
|
||||
Mappings mappings) {
|
||||
schema = BinderHelper.isDefault( schema ) ? mappings.getSchemaName() : schema;
|
||||
catalog = BinderHelper.isDefault( catalog ) ? mappings.getCatalogName() : catalog;
|
||||
schema = BinderHelper.isEmptyAnnotationValue( schema ) ? mappings.getSchemaName() : schema;
|
||||
catalog = BinderHelper.isEmptyAnnotationValue( catalog ) ? mappings.getCatalogName() : catalog;
|
||||
Table table;
|
||||
if ( denormalizedSuperTable != null ) {
|
||||
table = mappings.addDenormalizedTable(
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, 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
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.various;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.test.annotations.TestCase;
|
||||
|
||||
/**
|
||||
* Test for the @OptimisticLock annotation.
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class OptimisticLockAnnotationTest extends TestCase {
|
||||
|
||||
public void testOptimisticLockExcludeOnNameProperty() throws Exception {
|
||||
Conductor c = new Conductor();
|
||||
c.setName( "Bob" );
|
||||
Session s = openSession();
|
||||
s.getTransaction().begin();
|
||||
s.persist( c );
|
||||
s.flush();
|
||||
|
||||
s.clear();
|
||||
|
||||
c = ( Conductor ) s.get( Conductor.class, c.getId() );
|
||||
Long version = c.getVersion();
|
||||
c.setName( "Don" );
|
||||
s.flush();
|
||||
|
||||
s.clear();
|
||||
|
||||
c = ( Conductor ) s.get( Conductor.class, c.getId() );
|
||||
assertEquals( version, c.getVersion() );
|
||||
|
||||
s.getTransaction().rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
Conductor.class
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
//$Id$
|
||||
package org.hibernate.test.annotations.various;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.test.annotations.TestCase;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class VersionTest extends TestCase {
|
||||
|
||||
public void testOptimisticLockDisabled() throws Exception {
|
||||
Conductor c = new Conductor();
|
||||
c.setName( "Bob" );
|
||||
Session s = openSession( );
|
||||
s.getTransaction().begin();
|
||||
s.persist( c );
|
||||
s.flush();
|
||||
|
||||
s.clear();
|
||||
|
||||
c = (Conductor) s.get( Conductor.class, c.getId() );
|
||||
Long version = c.getVersion();
|
||||
c.setName( "Don" );
|
||||
s.flush();
|
||||
|
||||
s.clear();
|
||||
|
||||
c = (Conductor) s.get( Conductor.class, c.getId() );
|
||||
assertEquals( version, c.getVersion() );
|
||||
|
||||
s.getTransaction().rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
Conductor.class
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue