[hibernate-commits] Hibernate SVN: r11182 - in branches/Branch_3_2/HibernateExt/annotations/src: test/org/hibernate/test/annotations/query and 1 other directory.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Fri Feb 9 17:54:19 EST 2007
Author: epbernard
Date: 2007-02-09 17:54:18 -0500 (Fri, 09 Feb 2007)
New Revision: 11182
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/query/Chaos.java
Log:
ANN-551 order methods from VM to get consistent parameter ordering
Modified: branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java 2007-02-09 22:45:26 UTC (rev 11181)
+++ branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java 2007-02-09 22:54:18 UTC (rev 11182)
@@ -10,6 +10,8 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import java.util.Collections;
+import java.util.Comparator;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.DiscriminatorType;
@@ -164,43 +166,43 @@
Map defaults = mappings.getReflectionManager().getDefaults();
{
List<SequenceGenerator> anns = (List<SequenceGenerator>) defaults.get( SequenceGenerator.class );
- if (anns != null) {
+ if ( anns != null ) {
for ( SequenceGenerator ann : anns ) {
- IdGenerator idGen = buildIdGenerator(ann, mappings);
- if (idGen != null) mappings.addDefaultGenerator( idGen );
+ IdGenerator idGen = buildIdGenerator( ann, mappings );
+ if ( idGen != null ) mappings.addDefaultGenerator( idGen );
}
}
}
{
List<TableGenerator> anns = (List<TableGenerator>) defaults.get( TableGenerator.class );
- if (anns != null) {
+ if ( anns != null ) {
for ( TableGenerator ann : anns ) {
- IdGenerator idGen = buildIdGenerator(ann, mappings);
- if (idGen != null) mappings.addDefaultGenerator( idGen );
+ IdGenerator idGen = buildIdGenerator( ann, mappings );
+ if ( idGen != null ) mappings.addDefaultGenerator( idGen );
}
}
}
{
List<NamedQuery> anns = (List<NamedQuery>) defaults.get( NamedQuery.class );
- if (anns != null) {
- for (NamedQuery ann : anns) {
- QueryBinder.bindQuery(ann, mappings, true );
+ if ( anns != null ) {
+ for ( NamedQuery ann : anns ) {
+ QueryBinder.bindQuery( ann, mappings, true );
}
}
}
{
List<NamedNativeQuery> anns = (List<NamedNativeQuery>) defaults.get( NamedNativeQuery.class );
- if (anns != null) {
- for (NamedNativeQuery ann : anns) {
- QueryBinder.bindNativeQuery(ann, mappings, true );
+ if ( anns != null ) {
+ for ( NamedNativeQuery ann : anns ) {
+ QueryBinder.bindNativeQuery( ann, mappings, true );
}
}
}
{
List<SqlResultSetMapping> anns = (List<SqlResultSetMapping>) defaults.get( SqlResultSetMapping.class );
- if (anns != null) {
- for (SqlResultSetMapping ann : anns) {
- QueryBinder.bindSqlResultsetMapping(ann, mappings, true );
+ if ( anns != null ) {
+ for ( SqlResultSetMapping ann : anns ) {
+ QueryBinder.bindSqlResultsetMapping( ann, mappings, true );
}
}
}
@@ -308,24 +310,24 @@
idGen.setName( tabGen.name() );
idGen.setIdentifierGeneratorStrategy( MultipleHiLoPerTableGenerator.class.getName() );
- if ( ! BinderHelper.isDefault( tabGen.table() ) ) {
+ if ( !BinderHelper.isDefault( tabGen.table() ) ) {
idGen.addParam( MultipleHiLoPerTableGenerator.ID_TABLE, tabGen.table() );
}
- if ( ! BinderHelper.isDefault( tabGen.catalog() ) ) {
+ if ( !BinderHelper.isDefault( tabGen.catalog() ) ) {
idGen.addParam( MultipleHiLoPerTableGenerator.CATALOG, tabGen.catalog() );
}
- if ( ! BinderHelper.isDefault( tabGen.schema() ) ) {
+ if ( !BinderHelper.isDefault( tabGen.schema() ) ) {
idGen.addParam( MultipleHiLoPerTableGenerator.SCHEMA, tabGen.schema() );
}
//FIXME implements uniqueconstrains
- if ( ! BinderHelper.isDefault( tabGen.pkColumnName() ) ) {
+ if ( !BinderHelper.isDefault( tabGen.pkColumnName() ) ) {
idGen.addParam( MultipleHiLoPerTableGenerator.PK_COLUMN_NAME, tabGen.pkColumnName() );
}
- if ( ! BinderHelper.isDefault( tabGen.valueColumnName() ) ) {
+ if ( !BinderHelper.isDefault( tabGen.valueColumnName() ) ) {
idGen.addParam( MultipleHiLoPerTableGenerator.VALUE_COLUMN_NAME, tabGen.valueColumnName() );
}
- if ( ! BinderHelper.isDefault( tabGen.pkColumnValue() ) ) {
+ if ( !BinderHelper.isDefault( tabGen.pkColumnValue() ) ) {
idGen.addParam( MultipleHiLoPerTableGenerator.PK_VALUE_NAME, tabGen.pkColumnValue() );
}
idGen.addParam( TableHiLoGenerator.MAX_LO, String.valueOf( tabGen.allocationSize() - 1 ) );
@@ -336,7 +338,7 @@
idGen.setName( seqGen.name() );
idGen.setIdentifierGeneratorStrategy( "seqhilo" );
- if ( ! BinderHelper.isDefault( seqGen.sequenceName() ) ) {
+ if ( !BinderHelper.isDefault( seqGen.sequenceName() ) ) {
idGen.addParam( org.hibernate.id.SequenceGenerator.SEQUENCE, seqGen.sequenceName() );
}
//FIXME: work on initialValue() through SequenceGenerator.PARAMETERS
@@ -380,7 +382,7 @@
) {
return;
}
- if ( ! classType.equals( AnnotatedClassType.ENTITY ) ) {
+ if ( !classType.equals( AnnotatedClassType.ENTITY ) ) {
//TODO make this test accurate by removing the none elements artifically added
throw new AnnotationException(
"Annotated class should have a @javax.persistence.Entity, @javax.persistence.Embeddable or @javax.persistence.EmbeddedSuperclass annotation: " + clazzToProcess
@@ -393,9 +395,11 @@
InheritanceState.getSuperEntityInheritanceState(
clazzToProcess, inheritanceStatePerClass, mappings.getReflectionManager()
);
- PersistentClass superEntity = superEntityState != null ? mappings.getClass(
- superEntityState.clazz.getName()
- ) : null;
+ PersistentClass superEntity = superEntityState != null ?
+ mappings.getClass(
+ superEntityState.clazz.getName()
+ ) :
+ null;
if ( superEntity == null ) {
//check if superclass is not a potential persistent class
if ( inheritanceState.hasParents ) {
@@ -434,7 +438,7 @@
int nbrOfInhJoinedColumns = jcsAnn.value().length;
PrimaryKeyJoinColumn jcAnn;
inheritanceJoinedColumns = new Ejb3JoinColumn[nbrOfInhJoinedColumns];
- for ( int colIndex = 0; colIndex < nbrOfInhJoinedColumns ; colIndex++ ) {
+ for ( int colIndex = 0; colIndex < nbrOfInhJoinedColumns; colIndex++ ) {
jcAnn = jcsAnn.value()[colIndex];
inheritanceJoinedColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn(
jcAnn, null, superEntity.getIdentifier(),
@@ -464,12 +468,14 @@
javax.persistence.DiscriminatorColumn discAnn = annotatedClass.getAnnotation(
javax.persistence.DiscriminatorColumn.class
);
- DiscriminatorType discriminatorType = discAnn != null ? discAnn.discriminatorType() : DiscriminatorType.STRING;
+ DiscriminatorType discriminatorType = discAnn != null ?
+ discAnn.discriminatorType() :
+ DiscriminatorType.STRING;
org.hibernate.annotations.DiscriminatorFormula discFormulaAnn = annotatedClass.getAnnotation(
org.hibernate.annotations.DiscriminatorFormula.class
);
- if ( ! inheritanceState.hasParents ) {
+ if ( !inheritanceState.hasParents ) {
discriminatorColumn = Ejb3DiscriminatorColumn.buildDiscriminatorColumn(
discriminatorType, discAnn, discFormulaAnn, mappings
);
@@ -488,7 +494,7 @@
//we now know what kind of persistent entity it is
PersistentClass persistentClass;
//create persistent class
- if ( ! inheritanceState.hasParents ) {
+ if ( !inheritanceState.hasParents ) {
persistentClass = new RootClass();
}
else if ( InheritanceType.SINGLE_TABLE.equals( inheritanceState.type ) ) {
@@ -536,15 +542,20 @@
if ( inheritanceState.hasTable() ) {
Check checkAnn = annotatedClass.getAnnotation( Check.class );
- String constraints = checkAnn == null ? null : checkAnn.constraints();
+ String constraints = checkAnn == null ?
+ null :
+ checkAnn.constraints();
entityBinder.bindTable(
schema, catalog, table, uniqueConstraints,
- constraints, inheritanceState.hasDenormalizedTable() ? superEntity.getTable() : null
+ constraints, inheritanceState.hasDenormalizedTable() ?
+ superEntity.getTable() :
+ null
);
}
else {
if ( annotatedClass.isAnnotationPresent( Table.class ) ) {
- log.warn( "Illegal use of @Table in a subclass of a SINGLE_TABLE hierarchy: " + clazzToProcess.getName() );
+ log.warn( "Illegal use of @Table in a subclass of a SINGLE_TABLE hierarchy: " + clazzToProcess
+ .getName() );
}
}
// Map<String, Column[]> columnOverride = PropertyHolderBuilder.buildHierarchyColumnOverride(
@@ -593,7 +604,7 @@
}
}
else {
- if ( inheritanceState.hasSons || ! discriminatorColumn.isImplicit() ) {
+ if ( inheritanceState.hasSons || !discriminatorColumn.isImplicit() ) {
//need a discriminator column
bindDiscriminatorToPersistentClass(
(RootClass) persistentClass,
@@ -612,7 +623,7 @@
}
}
}
- if ( onDeleteAnn != null && ! onDeleteAppropriate ) {
+ if ( onDeleteAnn != null && !onDeleteAppropriate ) {
log.warn(
"Inapropriate use of @OnDelete on entity, annotation ignored: " + propertyHolder.getEntityName()
);
@@ -634,7 +645,7 @@
//process idclass if any
Set<String> idProperties = new HashSet<String>();
IdClass idClass = null;
- if ( ! inheritanceState.hasParents ) {
+ if ( !inheritanceState.hasParents ) {
//look for idClass
XClass current = inheritanceState.clazz;
InheritanceState state = inheritanceState;
@@ -709,10 +720,12 @@
Set<String> missingIdProperties = new HashSet<String>( idProperties );
for ( PropertyData propertyAnnotatedElement : elements ) {
String propertyName = propertyAnnotatedElement.getPropertyName();
- if ( ! idProperties.contains( propertyName ) ) {
+ if ( !idProperties.contains( propertyName ) ) {
processElementAnnotations(
propertyHolder,
- subclassAndSingleTableStrategy ? Nullability.FORCED_NULL : Nullability.NO_CONSTRAINT,
+ subclassAndSingleTableStrategy ?
+ Nullability.FORCED_NULL :
+ Nullability.NO_CONSTRAINT,
propertyAnnotatedElement.getProperty(),
propertyAnnotatedElement, classGenerators, entityBinder,
false, false, false, mappings
@@ -735,7 +748,7 @@
);
}
- if ( ! inheritanceState.hasParents ) {
+ if ( !inheritanceState.hasParents ) {
final RootClass rootClass = (RootClass) persistentClass;
//no need to handle inSecondPass this is an Etntiy related work
mappings.addSecondPass( new CreateKeySecondPass( rootClass ) );
@@ -770,7 +783,7 @@
int deep = classesToProcess.size();
boolean hasIdentifier = false;
- assert ! inheritanceState.isEmbeddableSuperclass;
+ assert !inheritanceState.isEmbeddableSuperclass;
Boolean isExplicitPropertyAnnotated = null;
String explicitAccessType = null;
if ( inheritanceState.hasParents ) {
@@ -778,12 +791,18 @@
InheritanceState.getSuperEntityInheritanceState(
clazzToProcess, inheritanceStatePerClass, mappings.getReflectionManager()
);
- isExplicitPropertyAnnotated = superEntityState != null ? superEntityState.isPropertyAnnotated : null;
- explicitAccessType = superEntityState != null ? superEntityState.accessType : null;
+ isExplicitPropertyAnnotated = superEntityState != null ?
+ superEntityState.isPropertyAnnotated :
+ null;
+ explicitAccessType = superEntityState != null ?
+ superEntityState.accessType :
+ null;
}
else {
AccessType access = clazzToProcess.getAnnotation( AccessType.class );
- explicitAccessType = access != null ? access.value() : null;
+ explicitAccessType = access != null ?
+ access.value() :
+ null;
if ( "property".equals( explicitAccessType ) ) {
isExplicitPropertyAnnotated = Boolean.TRUE;
}
@@ -792,13 +811,16 @@
}
}
Boolean isPropertyAnnotated = isExplicitPropertyAnnotated == null ?
- Boolean.TRUE : //default to property and fallback if needed
+ Boolean.TRUE :
+ //default to property and fallback if needed
isExplicitPropertyAnnotated;
- String accessType = explicitAccessType != null ? explicitAccessType : "property";
+ String accessType = explicitAccessType != null ?
+ explicitAccessType :
+ "property";
- for ( int index = 0; index < deep ; index++ ) {
+ for ( int index = 0; index < deep; index++ ) {
XClass clazz = classesToProcess.get( index );
-
+
boolean currentHasIdentifier = addElementsOfAClass(
elements, propertyHolder, isPropertyAnnotated,
accessType, clazz, mappings
@@ -811,7 +833,7 @@
isPropertyAnnotated = !isPropertyAnnotated;
accessType = "field";
elements.clear();
- for ( int index = 0; index < deep ; index++ ) {
+ for ( int index = 0; index < deep; index++ ) {
XClass clazz = classesToProcess.get( index );
boolean currentHasIdentifier = addElementsOfAClass(
elements, propertyHolder, isPropertyAnnotated,
@@ -825,7 +847,9 @@
entityBinder.setPropertyAccessor( accessType );
inheritanceState.isPropertyAnnotated = isPropertyAnnotated;
inheritanceState.accessType = accessType;
- return hasIdentifier || inheritanceState.hasParents ? elements : null;
+ return hasIdentifier || inheritanceState.hasParents ?
+ elements :
+ null;
}
private static List<XClass> orderClassesToBeProcessed(
@@ -843,7 +867,8 @@
superClass = superClass.getSuperclass();
superclassState = inheritanceStatePerClass.get( superClass );
}
- while ( superClass != null && !mappings.getReflectionManager().equals( superClass, Object.class ) && superclassState == null );
+ while ( superClass != null && !mappings.getReflectionManager()
+ .equals( superClass, Object.class ) && superclassState == null );
currentClassInHierarchy = superClass;
}
@@ -926,7 +951,9 @@
) {
boolean hasIdentifier = false;
AccessType access = annotatedClass.getAnnotation( AccessType.class );
- String localPropertyAccessor = access != null ? access.value() : null;
+ String localPropertyAccessor = access != null ?
+ access.value() :
+ null;
String accessType = null;
if ( "property".equals( localPropertyAccessor ) || "field".equals( localPropertyAccessor ) ) {
accessType = localPropertyAccessor;
@@ -946,6 +973,12 @@
log.debug( "Processing " + propertyHolder.getEntityName() + " " + accessType + " annotation" );
List<XProperty> properties = annotatedClass.getDeclaredProperties( accessType );
+ //order so that property are used int he same order when binding native query
+ Collections.sort( properties, new Comparator<XProperty>() {
+ public int compare(XProperty property1, XProperty property2) {
+ return property1.getName().compareTo( property2.getName() );
+ }
+ } );
for ( XProperty p : properties ) {
if ( !p.isTypeResolved() && !discoverTypeWithoutReflection( p ) && !mustBeSkipped( p, mappings ) ) {
throw new AnnotationException(
@@ -981,7 +1014,7 @@
.equals( void.class ) ) {
return true;
}
- else if (p.isAnnotationPresent( Type.class ) ) {
+ else if ( p.isAnnotationPresent( Type.class ) ) {
return true;
}
else if ( p.isAnnotationPresent( Target.class ) ) {
@@ -998,7 +1031,7 @@
PropertyData propertyAnnotatedElement = new PropertyInferredData(
property, propertyAccessor,
mappings.getReflectionManager() );
- if ( ! mustBeSkipped( propertyAnnotatedElement.getProperty(), mappings ) ) {
+ if ( !mustBeSkipped( propertyAnnotatedElement.getProperty(), mappings ) ) {
/*
* put element annotated by @Id in front
* since it has to be parsed before any assoctation by Hibernate
@@ -1139,7 +1172,7 @@
propertyHolder, inferredData.getPropertyName(), mappings
);
}
- if ( columns == null && ! property.isAnnotationPresent( ManyToMany.class ) ) {
+ if ( columns == null && !property.isAnnotationPresent( ManyToMany.class ) ) {
//useful for collection of embedded elements
columns = Ejb3Column.buildColumnFromAnnotation(
null, null, nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(), mappings
@@ -1176,8 +1209,12 @@
//if ( isComponent && embeddableAnn != null && embeddableAnn.access() == AccessType.FIELD ) propertyAccess = false;
GeneratedValue generatedValue = property.getAnnotation( GeneratedValue.class );
- String generatorType = generatedValue != null ? generatorType( generatedValue.strategy() ) : "assigned";
- String generator = generatedValue != null ? generatedValue.generator() : BinderHelper.ANNOTATION_STRING_DEFAULT;
+ String generatorType = generatedValue != null ?
+ generatorType( generatedValue.strategy() ) :
+ "assigned";
+ String generator = generatedValue != null ?
+ generatedValue.generator() :
+ BinderHelper.ANNOTATION_STRING_DEFAULT;
if ( isComponent ) generatorType = "assigned"; //a component must not have any generator
Type typeAnn = property.getAnnotation( Type.class );
bindId(
@@ -1196,7 +1233,9 @@
);
if ( log.isDebugEnabled() ) {
log.debug(
- "Bind " + ( isComponent ? "@EmbeddedId" : "@Id" ) + " on " + inferredData.getPropertyName()
+ "Bind " + ( isComponent ?
+ "@EmbeddedId" :
+ "@Id" ) + " on " + inferredData.getPropertyName()
);
}
}
@@ -1206,7 +1245,7 @@
"@IdClass class should not have @Version property"
);
}
- if ( ! ( propertyHolder.getPersistentClass() instanceof RootClass ) ) {
+ if ( !( propertyHolder.getPersistentClass() instanceof RootClass ) ) {
throw new AnnotationException(
"Unable to define/override @Version on a subclass: "
+ propertyHolder.getEntityName()
@@ -1245,7 +1284,7 @@
if ( property.isAnnotationPresent( Column.class )
|| property.isAnnotationPresent( Columns.class ) ) {
throw new AnnotationException( "@Column(s) not allowed on a @ManyToOne property: "
- + StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() ) );
+ + StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() ) );
}
Cascade hibernateCascade = property.getAnnotation( Cascade.class );
@@ -1276,8 +1315,8 @@
//check validity
if ( property.isAnnotationPresent( Column.class )
|| property.isAnnotationPresent( Columns.class ) ) {
- throw new AnnotationException( "@Column(s) not allowed on a @OneToOne property: "
- + StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() ) );
+ throw new AnnotationException( "@Column(s) not allowed on a @OneToOne property: "
+ + StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() ) );
}
//FIXME support a proper PKJCs
@@ -1323,7 +1362,7 @@
CollectionBinder collectionBinder = CollectionBinder.getCollectionBinder(
propertyHolder.getEntityName(),
property,
- ! indexColumn.isImplicit()
+ !indexColumn.isImplicit()
);
collectionBinder.setIndexColumn( indexColumn );
MapKey mapKeyAnn = property.getAnnotation( MapKey.class );
@@ -1389,7 +1428,9 @@
);
PropertyData mapKeyVirtualProperty = new WrappedInferredData( inferredData, "mapkey" );
Ejb3Column[] mapColumns = Ejb3Column.buildColumnFromAnnotation(
- hibMapKeyAnn != null && hibMapKeyAnn.columns().length > 0 ? hibMapKeyAnn.columns() : null,
+ hibMapKeyAnn != null && hibMapKeyAnn.columns().length > 0 ?
+ hibMapKeyAnn.columns() :
+ null,
null,
Nullability.FORCED_NOT_NULL,
propertyHolder,
@@ -1401,7 +1442,9 @@
MapKeyManyToMany mapKeyManyToMany = property.getAnnotation( MapKeyManyToMany.class );
Ejb3JoinColumn[] mapJoinColumns = Ejb3JoinColumn.buildJoinColumns(
- mapKeyManyToMany != null ? mapKeyManyToMany.joinColumns() : null,
+ mapKeyManyToMany != null ?
+ mapKeyManyToMany.joinColumns() :
+ null,
null, entityBinder.getSecondaryTables(),
propertyHolder, mapKeyVirtualProperty.getPropertyName(), mappings
);
@@ -1470,7 +1513,7 @@
if ( property.isAnnotationPresent( CollectionId.class ) ) { //do not compute the generators unless necessary
HashMap<String, IdGenerator> localGenerators = (HashMap<String, IdGenerator>) classGenerators.clone();
localGenerators.putAll( buildLocalGenerators( property, mappings ) );
- collectionBinder.setLocalGenerators(localGenerators);
+ collectionBinder.setLocalGenerators( localGenerators );
}
collectionBinder.bind();
@@ -1557,9 +1600,11 @@
JoinColumn[] annInverseJoins;
if ( joinTableAnn != null ) {
collectionBinder.setExplicitAssociationTable( true );
- if ( ! BinderHelper.isDefault( joinTableAnn.schema() ) ) associationTableBinder.setSchema( joinTableAnn.schema() );
- if ( ! BinderHelper.isDefault( joinTableAnn.catalog() ) ) associationTableBinder.setCatalog( joinTableAnn.catalog() );
- if ( ! BinderHelper.isDefault( joinTableAnn.name() ) ) associationTableBinder.setName( joinTableAnn.name() );
+ if ( !BinderHelper.isDefault( joinTableAnn.schema() ) )
+ associationTableBinder.setSchema( joinTableAnn.schema() );
+ if ( !BinderHelper.isDefault( joinTableAnn.catalog() ) )
+ associationTableBinder.setCatalog( joinTableAnn.catalog() );
+ if ( !BinderHelper.isDefault( joinTableAnn.name() ) ) associationTableBinder.setName( joinTableAnn.name() );
associationTableBinder.setUniqueConstraints( joinTableAnn.uniqueConstraints() );
//set check constaint in the second pass
@@ -1675,7 +1720,9 @@
}
for ( PropertyData propertyAnnotatedElement : classElements ) {
processElementAnnotations(
- subHolder, isNullable ? Nullability.NO_CONSTRAINT : Nullability.FORCED_NOT_NULL,
+ subHolder, isNullable ?
+ Nullability.NO_CONSTRAINT :
+ Nullability.FORCED_NOT_NULL,
propertyAnnotatedElement.getProperty(), propertyAnnotatedElement,
new HashMap<String, IdGenerator>(), entityBinder, isIdentifierMapper, isComponentEmbedded,
inSecondPass, mappings
@@ -1697,14 +1744,16 @@
* Fill simple value and property since and Id is a property
*/
PersistentClass persistentClass = propertyHolder.getPersistentClass();
- if ( ! ( persistentClass instanceof RootClass ) ) {
+ if ( !( persistentClass instanceof RootClass ) ) {
throw new AnnotationException(
"Unable to define/override @Id(s) on a subclass: "
+ propertyHolder.getEntityName()
);
}
RootClass rootClass = (RootClass) persistentClass;
- String persistentClassName = rootClass == null ? null : rootClass.getClassName();
+ String persistentClassName = rootClass == null ?
+ null :
+ rootClass.getClassName();
SimpleValue id;
if ( isComposite ) {
id = fillComponent(
@@ -1750,8 +1799,8 @@
}
private static void setupComponentTuplizer(XProperty property, Component component) {
- if (property == null) return;
- if (property.isAnnotationPresent( Tuplizers.class ) ) {
+ if ( property == null ) return;
+ if ( property.isAnnotationPresent( Tuplizers.class ) ) {
for ( Tuplizer tuplizer : property.getAnnotation( Tuplizers.class ).value() ) {
EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
component.addTuplizer( mode, tuplizer.impl().getName() );
@@ -1794,8 +1843,10 @@
value.setTypeUsingReflection( propertyHolder.getClassName(), propertyName );
ForeignKey fk = inferredData.getProperty().getAnnotation( ForeignKey.class );
- String fkName = fk != null ? fk.name() : "";
- if ( ! BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName );
+ String fkName = fk != null ?
+ fk.name() :
+ "";
+ if ( !BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName );
String path = propertyHolder.getPath() + "." + propertyName;
FkSecondPass secondPass = new FkSecondPass(
@@ -1804,7 +1855,7 @@
propertyHolder.getEntityOwnerClassName(),
path, mappings
);
- if (inSecondPass) {
+ if ( inSecondPass ) {
secondPass.doSecondPass( mappings.getClasses() );
}
else {
@@ -1850,7 +1901,7 @@
);
}
if ( lazy != null ) {
- toOne.setLazy( ! ( lazy.value() == LazyToOneOption.FALSE ) );
+ toOne.setLazy( !( lazy.value() == LazyToOneOption.FALSE ) );
toOne.setUnwrapProxy( ( lazy.value() == LazyToOneOption.NO_PROXY ) );
}
else {
@@ -1895,7 +1946,7 @@
final String propertyName = inferredData.getPropertyName();
log.debug( "Fetching " + propertyName + " with " + fetchMode );
boolean mapToPK = true;
- if ( ! trueOneToOne ) {
+ if ( !trueOneToOne ) {
//try to find a hidden true one to one (FK == PK columns)
Iterator idColumns = propertyHolder.getIdentifier().getColumnIterator();
List<String> idColumnNames = new ArrayList<String>();
@@ -1905,13 +1956,13 @@
idColumnNames.add( currentColumn.getName() );
}
for ( Ejb3JoinColumn col : joinColumns ) {
- if ( ! idColumnNames.contains( col.getMappingColumn().getName() ) ) {
+ if ( !idColumnNames.contains( col.getMappingColumn().getName() ) ) {
mapToPK = false;
break;
}
}
}
- if ( trueOneToOne || mapToPK || ! BinderHelper.isDefault( mappedBy ) ) {
+ if ( trueOneToOne || mapToPK || !BinderHelper.isDefault( mappedBy ) ) {
//is a true one-to-one
//FIXME referencedColumnName ignored => ordering may fail.
OneToOneSecondPass secondPass = new OneToOneSecondPass(
@@ -1921,7 +1972,7 @@
propertyHolder, inferredData, targetEntity, ignoreNotFound, cascadeOnDelete,
optional, cascadeStrategy, joinColumns, mappings
);
- if (inSecondPass) {
+ if ( inSecondPass ) {
secondPass.doSecondPass( mappings.getClasses() );
}
else {
@@ -1941,7 +1992,7 @@
}
private static String generatorType(GenerationType generatorEnum) {
- switch ( generatorEnum ) {
+ switch (generatorEnum) {
case IDENTITY:
return "identity";
case AUTO:
@@ -1958,7 +2009,7 @@
EnumSet<CascadeType> hibernateCascadeSet = EnumSet.noneOf( CascadeType.class );
if ( ejbCascades != null && ejbCascades.length > 0 ) {
for ( javax.persistence.CascadeType cascade : ejbCascades ) {
- switch ( cascade ) {
+ switch (cascade) {
case ALL:
hibernateCascadeSet.add( CascadeType.ALL );
break;
@@ -1985,7 +2036,9 @@
javax.persistence.CascadeType[] ejbCascades, Cascade hibernateCascadeAnnotation
) {
EnumSet<CascadeType> hibernateCascadeSet = convertToHibernateCascadeType( ejbCascades );
- CascadeType[] hibernateCascades = hibernateCascadeAnnotation == null ? null : hibernateCascadeAnnotation.value();
+ CascadeType[] hibernateCascades = hibernateCascadeAnnotation == null ?
+ null :
+ hibernateCascadeAnnotation.value();
if ( hibernateCascades != null && hibernateCascades.length > 0 ) {
for ( CascadeType cascadeType : hibernateCascades ) {
@@ -1996,7 +2049,7 @@
StringBuilder cascade = new StringBuilder();
Iterator<CascadeType> cascadeType = hibernateCascadeSet.iterator();
while ( cascadeType.hasNext() ) {
- switch ( cascadeType.next() ) {
+ switch (cascadeType.next()) {
case ALL:
cascade.append( "," ).append( "all" );
break;
@@ -2032,7 +2085,9 @@
break;
}
}
- return cascade.length() > 0 ? cascade.substring( 1 ) : "none";
+ return cascade.length() > 0 ?
+ cascade.substring( 1 ) :
+ "none";
}
public static FetchMode getFetchMode(FetchType fetch) {
@@ -2089,9 +2144,9 @@
reflectionManager
);
state.hasParents = superEntityState != null;
- final boolean nonDefault = state.type != null && ! InheritanceType.SINGLE_TABLE.equals( state.type );
+ final boolean nonDefault = state.type != null && !InheritanceType.SINGLE_TABLE.equals( state.type );
if ( superclassState.type != null ) {
- final boolean mixingStrategy = state.type != null && ! state.type.equals( superclassState.type );
+ final boolean mixingStrategy = state.type != null && !state.type.equals( superclassState.type );
if ( nonDefault && mixingStrategy ) {
log.warn(
"Mixing inheritance strategy in a entity hierarchy is not allowed, ignoring sub strategy in: " + clazz
Modified: branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/query/Chaos.java
===================================================================
--- branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/query/Chaos.java 2007-02-09 22:45:26 UTC (rev 11181)
+++ branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/query/Chaos.java 2007-02-09 22:54:18 UTC (rev 11182)
@@ -22,8 +22,8 @@
*/
@Entity
@Table(name="CHAOS")
- at SQLInsert( sql="INSERT INTO CHAOS(size, name, nickname, id) VALUES(?,upper(?),?,?)")
- at SQLUpdate( sql="UPDATE CHAOS SET size = ?, name = upper(?), nickname = ? WHERE id = ?")
+ at SQLInsert( sql="INSERT INTO CHAOS(name, nickname, size, id) VALUES(upper(?),?,?,?)")
+ at SQLUpdate( sql="UPDATE CHAOS SET name = upper(?), nickname = ?, size = ? WHERE id = ?")
@SQLDelete( sql="DELETE CHAOS WHERE id = ?")
@SQLDeleteAll( sql="DELETE CHAOS")
@Loader(namedQuery = "chaos")
More information about the hibernate-commits
mailing list