[hibernate-commits] Hibernate SVN: r12781 - in trunk/HibernateExt/annotations/src/java/org/hibernate/cfg: annotations and 1 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Thu Jul 19 18:28:14 EDT 2007
Author: epbernard
Date: 2007-07-19 18:28:14 -0400 (Thu, 19 Jul 2007)
New Revision: 12781
Modified:
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AbstractPropertyHolder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationConfiguration.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/BinderHelper.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ClassPropertyHolder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/CollectionPropertyHolder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ComponentPropertyHolder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3Column.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3DiscriminatorColumn.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3JoinColumn.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ExtendedMappings.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/FkSecondPass.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/InheritanceState.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/JoinedSubclassFkSecondPass.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/OneToOneSecondPass.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolderBuilder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyInferredData.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ToOneFkSecondPass.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/WrappedInferredData.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/EntityBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/IdBagBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/ListBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/MapBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/QueryBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3ReflectionManager.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/XMLContext.java
Log:
style
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AbstractPropertyHolder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AbstractPropertyHolder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AbstractPropertyHolder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -108,7 +108,7 @@
XClass current = element;
Map<String, Column[]> columnOverride = new HashMap<String, Column[]>();
Map<String, JoinColumn[]> joinColumnOverride = new HashMap<String, JoinColumn[]>();
- while ( current != null && ! mappings.getReflectionManager().toXClass( Object.class ).equals( current ) ) {
+ while ( current != null && !mappings.getReflectionManager().toXClass( Object.class ).equals( current ) ) {
if ( current.isAnnotationPresent( Entity.class ) || current.isAnnotationPresent( MappedSuperclass.class )
|| current.isAnnotationPresent( Embeddable.class ) ) {
//FIXME is embeddable override?
@@ -133,7 +133,7 @@
AttributeOverrides multipleOverrides = element.getAnnotation( AttributeOverrides.class );
AttributeOverride[] overrides;
if ( singleOverride != null ) {
- overrides = new AttributeOverride[]{singleOverride};
+ overrides = new AttributeOverride[] { singleOverride };
}
else if ( multipleOverrides != null ) {
overrides = multipleOverrides.value();
@@ -144,10 +144,10 @@
//fill overriden columns
if ( overrides != null ) {
- for ( AttributeOverride depAttr : overrides ) {
+ for (AttributeOverride depAttr : overrides) {
columnOverride.put(
StringHelper.qualify( path, depAttr.name() ),
- new Column[]{depAttr.column()}
+ new Column[] { depAttr.column() }
);
}
}
@@ -161,7 +161,7 @@
AssociationOverrides multipleOverrides = element.getAnnotation( AssociationOverrides.class );
AssociationOverride[] overrides;
if ( singleOverride != null ) {
- overrides = new AssociationOverride[]{singleOverride};
+ overrides = new AssociationOverride[] { singleOverride };
}
else if ( multipleOverrides != null ) {
overrides = multipleOverrides.value();
@@ -172,7 +172,7 @@
//fill overriden columns
if ( overrides != null ) {
- for ( AssociationOverride depAttr : overrides ) {
+ for (AssociationOverride depAttr : overrides) {
columnOverride.put(
StringHelper.qualify( path, depAttr.name() ),
depAttr.joinColumns()
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -2,6 +2,8 @@
package org.hibernate.cfg;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -10,8 +12,6 @@
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;
@@ -53,9 +53,9 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
+import org.hibernate.EntityMode;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
-import org.hibernate.EntityMode;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
@@ -73,8 +73,10 @@
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;
+import org.hibernate.annotations.Index;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
+import org.hibernate.annotations.ManyToAny;
import org.hibernate.annotations.MapKeyManyToMany;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.NotFound;
@@ -87,17 +89,18 @@
import org.hibernate.annotations.Parent;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.Sort;
+import org.hibernate.annotations.Target;
+import org.hibernate.annotations.Tuplizer;
+import org.hibernate.annotations.Tuplizers;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.hibernate.annotations.Where;
-import org.hibernate.annotations.Index;
-import org.hibernate.annotations.Target;
-import org.hibernate.annotations.Tuplizers;
-import org.hibernate.annotations.Tuplizer;
-import org.hibernate.annotations.AnyMetaDef;
-import org.hibernate.annotations.MetaValue;
-import org.hibernate.annotations.ManyToAny;
+import org.hibernate.annotations.common.reflection.ReflectionManager;
+import org.hibernate.annotations.common.reflection.XAnnotatedElement;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XPackage;
+import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.annotations.CollectionBinder;
import org.hibernate.cfg.annotations.EntityBinder;
import org.hibernate.cfg.annotations.Nullability;
@@ -111,11 +114,13 @@
import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.id.SequenceHiLoGenerator;
import org.hibernate.id.TableHiLoGenerator;
+import org.hibernate.mapping.Any;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.DependantValue;
import org.hibernate.mapping.IdGenerator;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.JoinedSubclass;
+import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
@@ -124,16 +129,9 @@
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.UnionSubclass;
-import org.hibernate.mapping.KeyValue;
-import org.hibernate.mapping.Any;
import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
import org.hibernate.persister.entity.SingleTableEntityPersister;
import org.hibernate.persister.entity.UnionSubclassEntityPersister;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
-import org.hibernate.annotations.common.reflection.XAnnotatedElement;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XPackage;
-import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.type.TypeFactory;
import org.hibernate.util.StringHelper;
@@ -173,7 +171,7 @@
{
List<SequenceGenerator> anns = (List<SequenceGenerator>) defaults.get( SequenceGenerator.class );
if ( anns != null ) {
- for ( SequenceGenerator ann : anns ) {
+ for (SequenceGenerator ann : anns) {
IdGenerator idGen = buildIdGenerator( ann, mappings );
if ( idGen != null ) mappings.addDefaultGenerator( idGen );
}
@@ -182,7 +180,7 @@
{
List<TableGenerator> anns = (List<TableGenerator>) defaults.get( TableGenerator.class );
if ( anns != null ) {
- for ( TableGenerator ann : anns ) {
+ for (TableGenerator ann : anns) {
IdGenerator idGen = buildIdGenerator( ann, mappings );
if ( idGen != null ) mappings.addDefaultGenerator( idGen );
}
@@ -191,7 +189,7 @@
{
List<NamedQuery> anns = (List<NamedQuery>) defaults.get( NamedQuery.class );
if ( anns != null ) {
- for ( NamedQuery ann : anns ) {
+ for (NamedQuery ann : anns) {
QueryBinder.bindQuery( ann, mappings, true );
}
}
@@ -199,7 +197,7 @@
{
List<NamedNativeQuery> anns = (List<NamedNativeQuery>) defaults.get( NamedNativeQuery.class );
if ( anns != null ) {
- for ( NamedNativeQuery ann : anns ) {
+ for (NamedNativeQuery ann : anns) {
QueryBinder.bindNativeQuery( ann, mappings, true );
}
}
@@ -207,7 +205,7 @@
{
List<SqlResultSetMapping> anns = (List<SqlResultSetMapping>) defaults.get( SqlResultSetMapping.class );
if ( anns != null ) {
- for ( SqlResultSetMapping ann : anns ) {
+ for (SqlResultSetMapping ann : anns) {
QueryBinder.bindSqlResultsetMapping( ann, mappings, true );
}
}
@@ -254,7 +252,7 @@
{
SqlResultSetMappings ann = annotatedElement.getAnnotation( SqlResultSetMappings.class );
if ( ann != null ) {
- for ( SqlResultSetMapping current : ann.value() ) {
+ for (SqlResultSetMapping current : ann.value()) {
QueryBinder.bindSqlResultsetMapping( current, mappings, false );
}
}
@@ -362,7 +360,7 @@
idGen.setName( genGen.name() );
idGen.setIdentifierGeneratorStrategy( genGen.strategy() );
Parameter[] params = genGen.parameters();
- for ( Parameter parameter : params ) {
+ for (Parameter parameter : params) {
idGen.addParam( parameter.name(), parameter.value() );
}
log.debug( "Add generic generator with name: " + idGen.getName() );
@@ -389,7 +387,7 @@
) {
if ( AnnotatedClassType.NONE.equals( classType )
&& clazzToProcess.isAnnotationPresent( org.hibernate.annotations.Entity.class ) ) {
- log.warn("Class annotated @org.hibernate.annotations.Entity but not javax.persistence.Entity "
+ log.warn( "Class annotated @org.hibernate.annotations.Entity but not javax.persistence.Entity "
+ "(most likely a user error): " + clazzToProcess.getName() );
}
return;
@@ -451,7 +449,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(),
@@ -547,7 +545,7 @@
}
Filters filtersAnn = annotatedClass.getAnnotation( Filters.class );
if ( filtersAnn != null ) {
- for ( Filter filter : filtersAnn.value() ) {
+ for (Filter filter : filtersAnn.value()) {
entityBinder.addFilter( filter.name(), filter.condition() );
}
}
@@ -600,7 +598,7 @@
SimpleValue key = new DependantValue( jsc.getTable(), jsc.getIdentifier() );
jsc.setKey( key );
ForeignKey fk = annotatedClass.getAnnotation( ForeignKey.class );
- if (fk != null && ! BinderHelper.isDefault( fk.name() ) ) {
+ if ( fk != null && !BinderHelper.isDefault( fk.name() ) ) {
key.setForeignKeyName( fk.name() );
}
if ( onDeleteAnn != null ) {
@@ -610,7 +608,7 @@
key.setCascadeDeleteEnabled( false );
}
//we are never in a second pass at that stage, so queue it
- SecondPass sp = new JoinedSubclassFkSecondPass(jsc, inheritanceJoinedColumns, key, mappings);
+ SecondPass sp = new JoinedSubclassFkSecondPass( jsc, inheritanceJoinedColumns, key, mappings );
mappings.addSecondPass( sp );
mappings.addSecondPass( new CreateKeySecondPass( jsc ) );
@@ -736,7 +734,7 @@
}
}
Set<String> missingIdProperties = new HashSet<String>( idProperties );
- for ( PropertyData propertyAnnotatedElement : elements ) {
+ for (PropertyData propertyAnnotatedElement : elements) {
String propertyName = propertyAnnotatedElement.getPropertyName();
if ( !idProperties.contains( propertyName ) ) {
processElementAnnotations(
@@ -756,7 +754,7 @@
if ( missingIdProperties.size() != 0 ) {
StringBuilder missings = new StringBuilder();
- for ( String property : missingIdProperties ) {
+ for (String property : missingIdProperties) {
missings.append( property ).append( ", " );
}
throw new AnnotationException(
@@ -776,7 +774,7 @@
mappings.addClass( persistentClass );
- mappings.addSecondPass( new SecondaryTableSecondPass(entityBinder, propertyHolder) );
+ mappings.addSecondPass( new SecondaryTableSecondPass( entityBinder, propertyHolder ) );
//entityBinder.finalSecondaryTableBinding( propertyHolder );
//add process complementary Table definition (index & all)
@@ -837,7 +835,7 @@
explicitAccessType :
"property";
- for ( int index = 0; index < deep; index++ ) {
+ for (int index = 0; index < deep; index++) {
XClass clazz = classesToProcess.get( index );
boolean currentHasIdentifier = addElementsOfAClass(
@@ -852,7 +850,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,
@@ -903,7 +901,7 @@
bindFilterDef( defAnn, mappings );
}
if ( defsAnn != null ) {
- for ( FilterDef def : defsAnn.value() ) {
+ for (FilterDef def : defsAnn.value()) {
bindFilterDef( def, mappings );
}
}
@@ -911,7 +909,7 @@
private static void bindFilterDef(FilterDef defAnn, ExtendedMappings mappings) {
Map<String, org.hibernate.type.Type> params = new HashMap<String, org.hibernate.type.Type>();
- for ( ParamDef param : defAnn.parameters() ) {
+ for (ParamDef param : defAnn.parameters()) {
params.put( param.name(), TypeFactory.heuristicType( param.type() ) );
}
FilterDefinition def = new FilterDefinition( defAnn.name(), defAnn.defaultCondition(), params );
@@ -926,7 +924,7 @@
bindTypeDef( defAnn, mappings );
}
if ( defsAnn != null ) {
- for ( TypeDef def : defsAnn.value() ) {
+ for (TypeDef def : defsAnn.value()) {
bindTypeDef( def, mappings );
}
}
@@ -934,7 +932,7 @@
private static void bindTypeDef(TypeDef defAnn, ExtendedMappings mappings) {
Properties params = new Properties();
- for ( Parameter param : defAnn.parameters() ) {
+ for (Parameter param : defAnn.parameters()) {
params.setProperty( param.name(), param.value() );
}
if ( log.isInfoEnabled() ) log.info( "Binding type definition: " + defAnn.name() );
@@ -998,7 +996,7 @@
return property1.getName().compareTo( property2.getName() );
}
} );
- for ( XProperty p : properties ) {
+ for (XProperty p : properties) {
if ( !p.isTypeResolved() && !discoverTypeWithoutReflection( p ) && !mustBeSkipped( p, mappings ) ) {
throw new AnnotationException(
"Property " + StringHelper.qualify( propertyHolder.getEntityName(), p.getName() ) +
@@ -1037,7 +1035,7 @@
return true;
}
else if ( p.isAnnotationPresent( ManyToAny.class ) ) {
- if ( ! p.isCollection() && ! p.isArray() ) {
+ if ( !p.isCollection() && !p.isArray() ) {
throw new AnnotationException( "@ManyToAny used on a non collection non array property: " + p.getName() );
}
return true;
@@ -1124,7 +1122,7 @@
{
JoinColumn[] anns = null;
if ( property.isAnnotationPresent( JoinColumn.class ) ) {
- anns = new JoinColumn[]{property.getAnnotation( JoinColumn.class )};
+ anns = new JoinColumn[] { property.getAnnotation( JoinColumn.class ) };
}
else if ( property.isAnnotationPresent( JoinColumns.class ) ) {
JoinColumns ann = property.getAnnotation( JoinColumns.class );
@@ -1145,7 +1143,7 @@
Column ann = property.getAnnotation( Column.class );
Formula formulaAnn = property.getAnnotation( Formula.class );
columns = Ejb3Column.buildColumnFromAnnotation(
- new Column[]{ann}, formulaAnn, nullability, propertyHolder, inferredData,
+ new Column[] { ann }, formulaAnn, nullability, propertyHolder, inferredData,
entityBinder.getSecondaryTables(), mappings
);
}
@@ -1201,7 +1199,7 @@
);
}
else if ( joinColumns == null && property.isAnnotationPresent( org.hibernate.annotations.Any.class ) ) {
- throw new AnnotationException("@Any requires an explicit @JoinColumn(s): "
+ throw new AnnotationException( "@Any requires an explicit @JoinColumn(s): "
+ StringHelper.qualify( propertyHolder.getPath(), property.getName() ) );
}
if ( columns == null && !property.isAnnotationPresent( ManyToMany.class ) ) {
@@ -1213,7 +1211,7 @@
if ( nullability == Nullability.FORCED_NOT_NULL ) {
//force columns to not null
- for ( Ejb3Column col : columns ) {
+ for (Ejb3Column col : columns) {
col.forceNotNull();
}
}
@@ -1326,7 +1324,7 @@
JoinTable assocTable = property.getAnnotation( JoinTable.class );
if ( assocTable != null ) {
Join join = propertyHolder.addJoin( assocTable, false );
- for ( Ejb3JoinColumn joinColumn : joinColumns ) {
+ for (Ejb3JoinColumn joinColumn : joinColumns) {
joinColumn.setSecondaryTableName( join.getTable().getName() );
}
}
@@ -1361,7 +1359,7 @@
JoinTable assocTable = property.getAnnotation( JoinTable.class );
if ( assocTable != null ) {
Join join = propertyHolder.addJoin( assocTable, false );
- for ( Ejb3JoinColumn joinColumn : joinColumns ) {
+ for (Ejb3JoinColumn joinColumn : joinColumns) {
joinColumn.setSecondaryTableName( join.getTable().getName() );
}
}
@@ -1393,7 +1391,7 @@
JoinTable assocTable = property.getAnnotation( JoinTable.class );
if ( assocTable != null ) {
Join join = propertyHolder.addJoin( assocTable, false );
- for ( Ejb3JoinColumn joinColumn : joinColumns ) {
+ for (Ejb3JoinColumn joinColumn : joinColumns) {
joinColumn.setSecondaryTableName( join.getTable().getName() );
}
}
@@ -1453,7 +1451,7 @@
Column ann = property.getAnnotation( Column.class );
Formula formulaAnn = property.getAnnotation( Formula.class );
elementColumns = Ejb3Column.buildColumnFromAnnotation(
- new Column[]{ann},
+ new Column[] { ann },
formulaAnn,
nullability,
propertyHolder,
@@ -1522,7 +1520,7 @@
}
String mappedBy = null;
if ( oneToManyAnn != null ) {
- for ( Ejb3JoinColumn column : joinColumns ) {
+ for (Ejb3JoinColumn column : joinColumns) {
if ( column.isSecondary() ) {
throw new NotYetImplementedException( "Collections having FK in secondary table" );
}
@@ -1536,7 +1534,7 @@
collectionBinder.setOneToMany( true );
}
else if ( collectionOfElementsAnn != null ) {
- for ( Ejb3JoinColumn column : joinColumns ) {
+ for (Ejb3JoinColumn column : joinColumns) {
if ( column.isSecondary() ) {
throw new NotYetImplementedException( "Collections having FK in secondary table" );
}
@@ -1557,7 +1555,7 @@
collectionBinder.setCascadeStrategy( getCascadeStrategy( manyToManyAnn.cascade(), hibernateCascade ) );
collectionBinder.setOneToMany( false );
}
- else if ( property.isAnnotationPresent( ManyToAny.class) ) {
+ else if ( property.isAnnotationPresent( ManyToAny.class ) ) {
mappedBy = "";
collectionBinder.setTargetEntity(
mappings.getReflectionManager().toXClass( void.class )
@@ -1617,7 +1615,7 @@
//implicit type will check basic types and Serializable classes
if ( !optional && nullability != Nullability.FORCED_NULL ) {
//force columns to not null
- for ( Ejb3Column col : columns ) {
+ for (Ejb3Column col : columns) {
col.forceNotNull();
}
}
@@ -1644,27 +1642,27 @@
Index index = property.getAnnotation( Index.class );
if ( index != null ) {
if ( joinColumns != null ) {
- for ( Ejb3Column column : joinColumns ) {
+ for (Ejb3Column column : joinColumns) {
column.addIndex( index, inSecondPass );
}
}
else {
- for ( Ejb3Column column : columns ) {
+ for (Ejb3Column column : columns) {
column.addIndex( index, inSecondPass );
}
}
}
NaturalId naturalIdAnn = property.getAnnotation( NaturalId.class );
- if(naturalIdAnn != null)
- {
- if(joinColumns != null) {
- for ( Ejb3Column column : joinColumns ) {
- column.addUniqueKey("_UniqueKey", inSecondPass);
+ if ( naturalIdAnn != null ) {
+ if ( joinColumns != null ) {
+ for (Ejb3Column column : joinColumns) {
+ column.addUniqueKey( "_UniqueKey", inSecondPass );
}
- } else {
- for ( Ejb3Column column : columns ) {
- column.addUniqueKey("_UniqueKey", inSecondPass);
+ }
+ else {
+ for (Ejb3Column column : columns) {
+ column.addUniqueKey( "_UniqueKey", inSecondPass );
}
}
}
@@ -1799,7 +1797,7 @@
);
superClass = superClass.getSuperclass();
}
- for ( PropertyData propertyAnnotatedElement : classElements ) {
+ for (PropertyData propertyAnnotatedElement : classElements) {
processElementAnnotations(
subHolder, isNullable ?
Nullability.NO_CONSTRAINT :
@@ -1854,7 +1852,7 @@
setupComponentTuplizer( property, componentId );
}
else {
- for ( Ejb3Column column : columns ) {
+ for (Ejb3Column column : columns) {
column.forceNotNull(); //this is an id
}
SimpleValueBinder value = new SimpleValueBinder();
@@ -1885,7 +1883,7 @@
private static void setupComponentTuplizer(XProperty property, Component component) {
if ( property == null ) return;
if ( property.isAnnotationPresent( Tuplizers.class ) ) {
- for ( Tuplizer tuplizer : property.getAnnotation( Tuplizers.class ).value() ) {
+ for (Tuplizer tuplizer : property.getAnnotation( Tuplizers.class ).value()) {
EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
component.addTuplizer( mode, tuplizer.impl().getName() );
}
@@ -1918,7 +1916,7 @@
value.setCascadeDeleteEnabled( cascadeOnDelete );
//value.setLazy( fetchMode != FetchMode.JOIN );
if ( !optional ) {
- for ( Ejb3JoinColumn column : columns ) {
+ for (Ejb3JoinColumn column : columns) {
column.setNullable( false );
}
}
@@ -2033,7 +2031,7 @@
if ( !trueOneToOne ) {
//try to find a hidden true one to one (FK == PK columns)
KeyValue identifier = propertyHolder.getIdentifier();
- if (identifier == null) {
+ if ( identifier == null ) {
//this is a @OneToOne in a @EmbeddedId (the persistentClass.identifier is not set yet, it's being built)
//by definition the PK cannot refers to itself so it cannot map to itself
mapToPK = false;
@@ -2046,7 +2044,7 @@
currentColumn = (org.hibernate.mapping.Column) idColumns.next();
idColumnNames.add( currentColumn.getName() );
}
- for ( Ejb3JoinColumn col : joinColumns ) {
+ for (Ejb3JoinColumn col : joinColumns) {
if ( !idColumnNames.contains( col.getMappingColumn().getName() ) ) {
mapToPK = false;
break;
@@ -2089,7 +2087,7 @@
boolean isIdentifierMapper, ExtendedMappings mappings
) {
org.hibernate.annotations.Any anyAnn = inferredData.getProperty().getAnnotation( org.hibernate.annotations.Any.class );
- if (anyAnn == null) {
+ if ( anyAnn == null ) {
throw new AssertionFailure( "Missing @Any annotation: "
+ StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() ) );
}
@@ -2118,7 +2116,7 @@
}
private static String generatorType(GenerationType generatorEnum) {
- switch (generatorEnum) {
+ switch ( generatorEnum ) {
case IDENTITY:
return "identity";
case AUTO:
@@ -2134,8 +2132,8 @@
private static EnumSet<CascadeType> convertToHibernateCascadeType(javax.persistence.CascadeType[] ejbCascades) {
EnumSet<CascadeType> hibernateCascadeSet = EnumSet.noneOf( CascadeType.class );
if ( ejbCascades != null && ejbCascades.length > 0 ) {
- for ( javax.persistence.CascadeType cascade : ejbCascades ) {
- switch (cascade) {
+ for (javax.persistence.CascadeType cascade : ejbCascades) {
+ switch ( cascade ) {
case ALL:
hibernateCascadeSet.add( CascadeType.ALL );
break;
@@ -2167,7 +2165,7 @@
hibernateCascadeAnnotation.value();
if ( hibernateCascades != null && hibernateCascades.length > 0 ) {
- for ( CascadeType cascadeType : hibernateCascades ) {
+ for (CascadeType cascadeType : hibernateCascades) {
hibernateCascadeSet.add( cascadeType );
}
}
@@ -2175,7 +2173,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;
@@ -2255,7 +2253,7 @@
Map<XClass, InheritanceState> inheritanceStatePerClass = new HashMap<XClass, InheritanceState>(
orderedClasses.size()
);
- for ( XClass clazz : orderedClasses ) {
+ for (XClass clazz : orderedClasses) {
InheritanceState superclassState = InheritanceState.getSuperclassInheritanceState(
clazz, inheritanceStatePerClass,
reflectionManager
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -31,20 +31,19 @@
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.hibernate.AnnotationException;
-import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
+import org.hibernate.annotations.AnyMetaDef;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.AnyMetaDef;
import org.hibernate.cfg.annotations.Version;
import org.hibernate.cfg.annotations.reflection.EJB3ReflectionManager;
-import org.hibernate.event.PreInsertEventListener;
-import org.hibernate.event.PreUpdateEventListener;
+import org.hibernate.event.PostDeleteEventListener;
import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.event.PostDeleteEventListener;
+import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.PreUpdateEventListener;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
@@ -106,9 +105,9 @@
//TODO remove embeddable
List<XClass> copy = new ArrayList<XClass>( original );
//for each class, copy all the relevent hierarchy
- for ( XClass clazz : original ) {
+ for (XClass clazz : original) {
XClass superClass = clazz.getSuperclass();
- while ( superClass != null && ! reflectionManager.equals( superClass, Object.class ) && ! copy.contains( superClass ) ) {
+ while ( superClass != null && !reflectionManager.equals( superClass, Object.class ) && !copy.contains( superClass ) ) {
if ( superClass.isAnnotationPresent( Entity.class )
|| superClass.isAnnotationPresent( MappedSuperclass.class ) ) {
copy.add( superClass );
@@ -249,7 +248,7 @@
//build annotatedClassEntities
{
List<XClass> tempAnnotatedClasses = new ArrayList<XClass>( annotatedClasses.size() );
- for ( XClass clazz : annotatedClasses ) {
+ for (XClass clazz : annotatedClasses) {
if ( clazz.isAnnotationPresent( Entity.class ) ) {
annotatedClassEntities.put( clazz.getName(), clazz );
tempAnnotatedClasses.add( clazz );
@@ -263,7 +262,7 @@
}
//process default values first
- if ( ! isDefaultProcessed ) {
+ if ( !isDefaultProcessed ) {
AnnotationBinder.bindDefaults( createExtendedMappings() );
isDefaultProcessed = true;
}
@@ -272,7 +271,7 @@
if ( precedence == null ) precedence = getProperties().getProperty( ARTEFACT );
if ( precedence == null ) precedence = DEFAULT_PRECEDENCE;
StringTokenizer precedences = new StringTokenizer( precedence, ",; ", false );
- if ( ! precedences.hasMoreElements() ) {
+ if ( !precedences.hasMoreElements() ) {
throw new MappingException( ARTEFACT + " cannot be empty: " + precedence );
}
while ( precedences.hasMoreElements() ) {
@@ -282,7 +281,7 @@
}
int cacheNbr = caches.size();
- for ( int index = 0; index < cacheNbr ; index++ ) {
+ for (int index = 0; index < cacheNbr; index++) {
CacheHolder cacheHolder = caches.get( index );
if ( cacheHolder.isClass ) {
super.setCacheConcurrencyStrategy(
@@ -328,7 +327,7 @@
table = (Table) entry.getKey();
List<String[]> uniqueConstraints = (List<String[]>) entry.getValue();
uniqueIndexPerTable = 0;
- for ( String[] columnNames : uniqueConstraints ) {
+ for (String[] columnNames : uniqueConstraints) {
keyName = "key" + uniqueIndexPerTable++;
buildUniqueKeyFromColumnNames( columnNames, table, keyName );
}
@@ -341,22 +340,22 @@
Constructor validatorCtr = null;
Method applyMethod = null;
try {
- Class classValidator = ReflectHelper.classForName("org.hibernate.validator.ClassValidator", this.getClass() );
- Class messageInterpolator = ReflectHelper.classForName("org.hibernate.validator.MessageInterpolator", this.getClass() );
+ Class classValidator = ReflectHelper.classForName( "org.hibernate.validator.ClassValidator", this.getClass() );
+ Class messageInterpolator = ReflectHelper.classForName( "org.hibernate.validator.MessageInterpolator", this.getClass() );
validatorCtr = classValidator.getDeclaredConstructor( new Class[] {
Class.class, ResourceBundle.class, messageInterpolator, Map.class, ReflectionManager.class
- }
+ }
);
applyMethod = classValidator.getMethod( "apply", PersistentClass.class );
}
catch (ClassNotFoundException e) {
- log.info( "Hibernate Validator not found: ignoring");
+ log.info( "Hibernate Validator not found: ignoring" );
}
catch (NoSuchMethodException e) {
- throw new AnnotationException(e);
+ throw new AnnotationException( e );
}
- if ( applyMethod != null && applyOnDdl) {
- for ( PersistentClass persistentClazz : (Collection<PersistentClass>) classes.values() ) {
+ if ( applyMethod != null && applyOnDdl ) {
+ for (PersistentClass persistentClazz : (Collection<PersistentClass>) classes.values()) {
//integrate the validate framework
String className = persistentClazz.getClassName();
if ( StringHelper.isNotEmpty( className ) ) {
@@ -367,7 +366,7 @@
applyMethod.invoke( validator, persistentClazz );
}
catch (Exception e) {
- log.warn("Unable to apply constraints on DDL for " + className, e);
+ log.warn( "Unable to apply constraints on DDL for " + className, e );
}
}
}
@@ -388,7 +387,7 @@
int compare = f1.getValue().getTable().getQuotedName().compareTo(
f2.getValue().getTable().getQuotedName()
);
- if (compare == 0) {
+ if ( compare == 0 ) {
//same table, we still need to differenciate true equality
if ( f1.hashCode() < f2.hashCode() ) {
compare = -1;
@@ -424,7 +423,7 @@
PersistentClass classMapping = getClassMapping( referenceEntityName );
if ( sp.isInPrimaryKey() ) {
String dependentTable = classMapping.getTable().getQuotedName();
- if ( ! isADependencyOf.containsKey( dependentTable ) ) {
+ if ( !isADependencyOf.containsKey( dependentTable ) ) {
isADependencyOf.put( dependentTable, new HashSet<String>() );
}
String table = sp.getValue().getTable().getQuotedName();
@@ -433,7 +432,7 @@
int beBefore = orderedFkSecondPasses.size();
Set<String> dependencies = isADependencyOf.get( table );
if ( dependencies != null ) {
- for ( String tableDep : dependencies ) {
+ for (String tableDep : dependencies) {
//for each declared dependency take the lowest index
int index = orderedTable.indexOf( tableDep );
//index = -1 when we have a self dependency
@@ -477,7 +476,7 @@
private void processArtifactsOfType(String artifact) {
if ( "hbm".equalsIgnoreCase( artifact ) ) {
log.debug( "Process hbm files" );
- for ( Document document : hbmDocuments ) {
+ for (Document document : hbmDocuments) {
super.add( document );
}
hbmDocuments.clear();
@@ -491,7 +490,7 @@
orderedClasses, reflectionManager
);
ExtendedMappings mappings = createExtendedMappings();
- for ( XClass clazz : orderedClasses ) {
+ for (XClass clazz : orderedClasses) {
//todo use the same extended mapping
AnnotationBinder.bindClass( clazz, inheritanceStatePerClass, mappings );
}
@@ -505,7 +504,7 @@
private void removeConflictedArtifact(String artifact) {
if ( "hbm".equalsIgnoreCase( artifact ) ) {
- for ( String entity : hbmEntities.keySet() ) {
+ for (String entity : hbmEntities.keySet()) {
if ( annotatedClassEntities.containsKey( entity ) ) {
annotatedClasses.remove( annotatedClassEntities.get( entity ) );
annotatedClassEntities.remove( entity );
@@ -513,7 +512,7 @@
}
}
else if ( "class".equalsIgnoreCase( artifact ) ) {
- for ( String entity : annotatedClassEntities.keySet() ) {
+ for (String entity : annotatedClassEntities.keySet()) {
if ( hbmEntities.containsKey( entity ) ) {
hbmDocuments.remove( hbmEntities.get( entity ) );
hbmEntities.remove( entity );
@@ -529,7 +528,7 @@
Set<Column> unbound = new HashSet<Column>();
Set<Column> unboundNoLogical = new HashSet<Column>();
ExtendedMappings mappings = createExtendedMappings();
- for ( int index = 0; index < size ; index++ ) {
+ for (int index = 0; index < size; index++) {
String columnName;
try {
columnName = mappings.getPhysicalColumnName( columnNames[index], table );
@@ -537,11 +536,11 @@
unbound.add( columns[index] );
//column equals and hashcode is based on column name
}
- catch( MappingException e ) {
+ catch (MappingException e) {
unboundNoLogical.add( new Column( columnNames[index] ) );
}
}
- for ( Column column : columns ) {
+ for (Column column : columns) {
if ( table.containsColumn( column ) ) {
uc = table.getOrCreateUniqueKey( keyName );
uc.addColumn( table.getColumn( column ) );
@@ -550,15 +549,15 @@
}
if ( unbound.size() > 0 || unboundNoLogical.size() > 0 ) {
StringBuilder sb = new StringBuilder( "Unable to create unique key constraint (" );
- for ( String columnName : columnNames ) {
+ for (String columnName : columnNames) {
sb.append( columnName ).append( ", " );
}
sb.setLength( sb.length() - 2 );
sb.append( ") on table " ).append( table.getName() ).append( ": " );
- for ( Column column : unbound ) {
+ for (Column column : unbound) {
sb.append( column.getName() ).append( ", " );
}
- for ( Column column : unboundNoLogical ) {
+ for (Column column : unboundNoLogical) {
sb.append( column.getName() ).append( ", " );
}
sb.setLength( sb.length() - 2 );
@@ -624,7 +623,7 @@
if ( !ejb3Xml ) super.add( doc );
}
else {
- if ( ! ejb3Xml ) {
+ if ( !ejb3Xml ) {
final Element hmNode = doc.getRootElement();
Attribute packNode = hmNode.attribute( "package" );
String defaultPackage = packNode != null
@@ -632,14 +631,14 @@
: "";
Set<String> entityNames = new HashSet<String>();
findClassNames( defaultPackage, hmNode, entityNames );
- for ( String entity : entityNames ) {
+ for (String entity : entityNames) {
hbmEntities.put( entity, doc );
}
hbmDocuments.add( doc );
}
else {
List<String> classnames = ( (EJB3ReflectionManager) reflectionManager ).getXMLContext().addDocument( doc );
- for ( String classname : classnames ) {
+ for (String classname : classnames) {
try {
annotatedClasses.add( reflectionManager.classForName( classname, this.getClass() ) );
}
@@ -744,7 +743,7 @@
public SessionFactory buildSessionFactory() throws HibernateException {
//add validator events if the jar is available
- boolean enableValidatorListeners = ! "false".equalsIgnoreCase( getProperty( "hibernate.validator.autoregister_listeners" ) );
+ boolean enableValidatorListeners = !"false".equalsIgnoreCase( getProperty( "hibernate.validator.autoregister_listeners" ) );
Class validateEventListenerClass = null;
try {
validateEventListenerClass = ReflectHelper.classForName(
@@ -755,31 +754,31 @@
//validator is not present
log.debug( "Validator not present in classpath, ignoring event listener registration" );
}
- if (enableValidatorListeners && validateEventListenerClass != null) {
+ if ( enableValidatorListeners && validateEventListenerClass != null ) {
//TODO so much duplication
Object validateEventListener;
try {
validateEventListener = validateEventListenerClass.newInstance();
}
catch (Exception e) {
- throw new AnnotationException("Unable to load Validator event listener", e );
+ throw new AnnotationException( "Unable to load Validator event listener", e );
}
{
boolean present = false;
PreInsertEventListener[] listeners = getEventListeners().getPreInsertEventListeners();
- if (listeners != null) {
- for ( Object eventListener : listeners ) {
+ if ( listeners != null ) {
+ for (Object eventListener : listeners) {
//not isAssignableFrom since the user could subclass
present = present || validateEventListenerClass == eventListener.getClass();
}
- if (!present) {
+ if ( !present ) {
int length = listeners.length + 1;
PreInsertEventListener[] newListeners = new PreInsertEventListener[length];
- for ( int i = 0 ; i < length - 1 ; i++ ) {
+ for (int i = 0; i < length - 1; i++) {
newListeners[i] = listeners[i];
}
- newListeners[length-1] = (PreInsertEventListener) validateEventListener;
- getEventListeners().setPreInsertEventListeners(newListeners);
+ newListeners[length - 1] = (PreInsertEventListener) validateEventListener;
+ getEventListeners().setPreInsertEventListeners( newListeners );
}
}
else {
@@ -793,19 +792,19 @@
{
boolean present = false;
PreUpdateEventListener[] listeners = getEventListeners().getPreUpdateEventListeners();
- if (listeners != null) {
- for ( Object eventListener : listeners ) {
+ if ( listeners != null ) {
+ for (Object eventListener : listeners) {
//not isAssignableFrom since the user could subclass
present = present || validateEventListenerClass == eventListener.getClass();
}
- if (!present) {
+ if ( !present ) {
int length = listeners.length + 1;
PreUpdateEventListener[] newListeners = new PreUpdateEventListener[length];
- for ( int i = 0 ; i < length - 1 ; i++ ) {
+ for (int i = 0; i < length - 1; i++) {
newListeners[i] = listeners[i];
}
- newListeners[length-1] = (PreUpdateEventListener) validateEventListener;
- getEventListeners().setPreUpdateEventListeners(newListeners);
+ newListeners[length - 1] = (PreUpdateEventListener) validateEventListener;
+ getEventListeners().setPreUpdateEventListeners( newListeners );
}
}
else {
@@ -817,7 +816,7 @@
}
//add search events if the jar is available
- boolean enableSearchListeners = ! "false".equalsIgnoreCase( getProperty( "hibernate.search.autoregister_listeners" ) );
+ boolean enableSearchListeners = !"false".equalsIgnoreCase( getProperty( "hibernate.search.autoregister_listeners" ) );
Class searchEventListenerClass = null;
try {
searchEventListenerClass = ReflectHelper.classForName(
@@ -828,31 +827,31 @@
//search is not present
log.debug( "Search not present in classpath, ignoring event listener registration" );
}
- if (enableSearchListeners && searchEventListenerClass != null) {
+ if ( enableSearchListeners && searchEventListenerClass != null ) {
//TODO so much duplication
Object searchEventListener;
try {
searchEventListener = searchEventListenerClass.newInstance();
}
catch (Exception e) {
- throw new AnnotationException("Unable to load Search event listener", e );
+ throw new AnnotationException( "Unable to load Search event listener", e );
}
{
boolean present = false;
PostInsertEventListener[] listeners = getEventListeners().getPostInsertEventListeners();
- if (listeners != null) {
- for ( Object eventListener : listeners ) {
+ if ( listeners != null ) {
+ for (Object eventListener : listeners) {
//not isAssignableFrom since the user could subclass
present = present || searchEventListenerClass == eventListener.getClass();
}
- if (!present) {
+ if ( !present ) {
int length = listeners.length + 1;
PostInsertEventListener[] newListeners = new PostInsertEventListener[length];
- for ( int i = 0 ; i < length - 1 ; i++ ) {
+ for (int i = 0; i < length - 1; i++) {
newListeners[i] = listeners[i];
}
- newListeners[length-1] = (PostInsertEventListener) searchEventListener;
- getEventListeners().setPostInsertEventListeners(newListeners);
+ newListeners[length - 1] = (PostInsertEventListener) searchEventListener;
+ getEventListeners().setPostInsertEventListeners( newListeners );
}
}
else {
@@ -864,19 +863,19 @@
{
boolean present = false;
PostUpdateEventListener[] listeners = getEventListeners().getPostUpdateEventListeners();
- if (listeners != null) {
- for ( Object eventListener : listeners ) {
+ if ( listeners != null ) {
+ for (Object eventListener : listeners) {
//not isAssignableFrom since the user could subclass
present = present || searchEventListenerClass == eventListener.getClass();
}
- if (!present) {
+ if ( !present ) {
int length = listeners.length + 1;
PostUpdateEventListener[] newListeners = new PostUpdateEventListener[length];
- for ( int i = 0 ; i < length - 1 ; i++ ) {
+ for (int i = 0; i < length - 1; i++) {
newListeners[i] = listeners[i];
}
- newListeners[length-1] = (PostUpdateEventListener) searchEventListener;
- getEventListeners().setPostUpdateEventListeners(newListeners);
+ newListeners[length - 1] = (PostUpdateEventListener) searchEventListener;
+ getEventListeners().setPostUpdateEventListeners( newListeners );
}
}
else {
@@ -888,19 +887,19 @@
{
boolean present = false;
PostDeleteEventListener[] listeners = getEventListeners().getPostDeleteEventListeners();
- if (listeners != null) {
- for ( Object eventListener : listeners ) {
+ if ( listeners != null ) {
+ for (Object eventListener : listeners) {
//not isAssignableFrom since the user could subclass
present = present || searchEventListenerClass == eventListener.getClass();
}
- if (!present) {
+ if ( !present ) {
int length = listeners.length + 1;
PostDeleteEventListener[] newListeners = new PostDeleteEventListener[length];
- for ( int i = 0 ; i < length - 1 ; i++ ) {
+ for (int i = 0; i < length - 1; i++) {
newListeners[i] = listeners[i];
}
- newListeners[length-1] = (PostDeleteEventListener) searchEventListener;
- getEventListeners().setPostDeleteEventListeners(newListeners);
+ newListeners[length - 1] = (PostDeleteEventListener) searchEventListener;
+ getEventListeners().setPostDeleteEventListeners( newListeners );
}
}
else {
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/BinderHelper.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/BinderHelper.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/BinderHelper.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -8,43 +8,40 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
-import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
-import org.hibernate.type.TypeFactory;
import org.hibernate.annotations.AnyMetaDef;
-import org.hibernate.annotations.MetaValue;
-import org.hibernate.annotations.TypeDef;
-import org.hibernate.annotations.TypeDefs;
-import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.AnyMetaDefs;
+import org.hibernate.annotations.MetaValue;
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XPackage;
-import org.hibernate.id.PersistentIdentifierGenerator;
-import org.hibernate.id.MultipleHiLoPerTableGenerator;
-import org.hibernate.cfg.annotations.TableBinder;
-import org.hibernate.cfg.annotations.Nullability;
import org.hibernate.cfg.annotations.EntityBinder;
+import org.hibernate.cfg.annotations.Nullability;
+import org.hibernate.cfg.annotations.TableBinder;
+import org.hibernate.id.MultipleHiLoPerTableGenerator;
+import org.hibernate.id.PersistentIdentifierGenerator;
+import org.hibernate.mapping.Any;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
+import org.hibernate.mapping.IdGenerator;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
+import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
-import org.hibernate.mapping.SimpleValue;
-import org.hibernate.mapping.IdGenerator;
-import org.hibernate.mapping.Any;
+import org.hibernate.type.TypeFactory;
import org.hibernate.util.StringHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* @author Emmanuel Bernard
@@ -131,7 +128,7 @@
embeddedComp.setEmbedded( true );
embeddedComp.setNodeName( syntheticPropertyName );
embeddedComp.setComponentClassName( embeddedComp.getOwner().getClassName() );
- for ( Property property : properties ) {
+ for (Property property : properties) {
Property clone = BinderHelper.shallowCopy( property );
clone.setInsertable( false );
clone.setUpdateable( false );
@@ -140,7 +137,7 @@
}
synthProp = new Property();
synthProp.setName( syntheticPropertyName );
- synthProp.setNodeName(syntheticPropertyName);
+ synthProp.setNodeName( syntheticPropertyName );
synthProp.setPersistentClass( ownerEntity );
synthProp.setUpdateable( false );
synthProp.setInsertable( false );
@@ -154,7 +151,7 @@
//TODO use a ToOne type doing a second select
StringBuilder columnsList = new StringBuilder();
columnsList.append( "referencedColumnNames(" );
- for ( Ejb3JoinColumn column : columns ) {
+ for (Ejb3JoinColumn column : columns) {
columnsList.append( column.getReferencedColumn() ).append( ", " );
}
columnsList.setLength( columnsList.length() - 2 );
@@ -231,7 +228,7 @@
);
}
//build the list of column names
- for ( Ejb3JoinColumn column1 : columns ) {
+ for (Ejb3JoinColumn column1 : columns) {
Column column = new Column(
mappings.getPhysicalColumnName( column1.getReferencedColumn(), referencedTable )
);
@@ -245,7 +242,7 @@
while ( it.hasNext() ) {
matchColumnsByProperty( (Property) it.next(), columnsToProperty );
}
- if (isPersistentClass) {
+ if ( isPersistentClass ) {
matchColumnsByProperty( ( (PersistentClass) columnOwner ).getIdentifierProperty(), columnsToProperty );
}
@@ -253,9 +250,9 @@
//only check 1 columns properties
//TODO make it smarter by checking correctly ordered multi column properties
List<Property> orderedProperties = new ArrayList<Property>();
- for ( Column column : orderedColumns ) {
+ for (Column column : orderedColumns) {
boolean found = false;
- for ( Property property : columnsToProperty.get( column ) ) {
+ for (Property property : columnsToProperty.get( column )) {
if ( property.getColumnSpan() == 1 ) {
orderedProperties.add( property );
found = true;
@@ -319,7 +316,7 @@
property = associatedClass.getProperty( element );
}
else {
- if ( ! property.isComposite() ) return null;
+ if ( !property.isComposite() ) return null;
property = ( (Component) property.getValue() ).getProperty( element );
}
}
@@ -336,7 +333,7 @@
property = associatedClass.getIdentifierMapper().getProperty( element );
}
else {
- if ( ! property.isComposite() ) return null;
+ if ( !property.isComposite() ) return null;
property = ( (Component) property.getValue() ).getProperty( element );
}
}
@@ -384,7 +381,7 @@
//swallow it
}
Iterator joins = current.getJoinIterator();
- while ( ! found && joins.hasNext() ) {
+ while ( !found && joins.hasNext() ) {
result = joins.next();
currentTable = ( (Join) result ).getTable();
try {
@@ -401,7 +398,9 @@
return found ? result : null;
}
- /** apply an id generator to a SimpleValue */
+ /**
+ * apply an id generator to a SimpleValue
+ */
public static void makeIdGenerator(
SimpleValue id, String generatorType, String generatorName, ExtendedMappings mappings,
Map<String, IdGenerator> localGenerators
@@ -422,7 +421,7 @@
( (org.hibernate.mapping.Column) id.getColumnIterator().next() ).getName()
);
}
- if ( ! isDefault( generatorName ) ) {
+ if ( !isDefault( generatorName ) ) {
//we have a named generator
IdGenerator gen = mappings.getGenerator( generatorName, localGenerators );
if ( gen == null ) {
@@ -435,7 +434,7 @@
identifierGeneratorStrategy.equals( "identity" )
|| identifierGeneratorStrategy.equals( "seqhilo" )
|| identifierGeneratorStrategy.equals( MultipleHiLoPerTableGenerator.class.getName() );
- if ( generatorType == null || ! avoidOverriding ) {
+ if ( generatorType == null || !avoidOverriding ) {
id.setIdentifierGeneratorStrategy( identifierGeneratorStrategy );
}
//checkIfMatchingGenerator(gen, generatorType, generatorName);
@@ -455,8 +454,8 @@
}
public static Any buildAnyValue(String anyMetaDefName, Ejb3JoinColumn[] columns, javax.persistence.Column metaColumn, PropertyData inferredData,
- boolean cascadeOnDelete, Nullability nullability, PropertyHolder propertyHolder,
- EntityBinder entityBinder, boolean optional, ExtendedMappings mappings) {
+ boolean cascadeOnDelete, Nullability nullability, PropertyHolder propertyHolder,
+ EntityBinder entityBinder, boolean optional, ExtendedMappings mappings) {
//All FK columns should be in the same table
Any value = new Any( columns[0].getTable() );
AnyMetaDef metaAnnDef = inferredData.getProperty().getAnnotation( AnyMetaDef.class );
@@ -468,22 +467,22 @@
else {
metaAnnDef = mappings.getAnyMetaDef( anyMetaDefName );
}
- if (metaAnnDef != null) {
+ if ( metaAnnDef != null ) {
value.setIdentifierType( metaAnnDef.idType() );
value.setMetaType( metaAnnDef.metaType() );
HashMap values = new HashMap();
org.hibernate.type.Type metaType = TypeFactory.heuristicType( value.getMetaType() );
- for (MetaValue metaValue : metaAnnDef.metaValues() ) {
+ for (MetaValue metaValue : metaAnnDef.metaValues()) {
try {
Object discrim = ( (org.hibernate.type.DiscriminatorType) metaType ).stringToObject( metaValue
- .value() );
+ .value() );
String entityName = metaValue.targetEntity().getName();
values.put( discrim, entityName );
}
catch (ClassCastException cce) {
throw new MappingException( "metaType was not a DiscriminatorType: "
- + metaType.getName() );
+ + metaType.getName() );
}
catch (Exception e) {
throw new MappingException( "could not interpret metaValue", e );
@@ -498,7 +497,7 @@
value.setCascadeDeleteEnabled( cascadeOnDelete );
if ( !optional ) {
- for ( Ejb3JoinColumn column : columns ) {
+ for (Ejb3JoinColumn column : columns) {
column.setNullable( false );
}
}
@@ -510,14 +509,14 @@
column.setTable( value.getTable() );
}
//meta column
- for ( Ejb3Column column : metaColumns ) {
+ for (Ejb3Column column : metaColumns) {
column.linkWithValue( value );
}
//id columns
final String propertyName = inferredData.getPropertyName();
Ejb3Column.checkPropertyConsistency( columns, propertyHolder.getEntityName() + propertyName );
- for ( Ejb3JoinColumn column : columns ) {
+ for (Ejb3JoinColumn column : columns) {
column.linkWithValue( value );
}
return value;
@@ -533,7 +532,7 @@
bindAnyMetaDef( defAnn, mappings );
}
if ( defsAnn != null ) {
- for ( AnyMetaDef def : defsAnn.value() ) {
+ for (AnyMetaDef def : defsAnn.value()) {
checkAnyMetaDefValidity( mustHaveName, def, annotatedElement );
bindAnyMetaDef( def, mappings );
}
@@ -545,7 +544,7 @@
String name = XClass.class.isAssignableFrom( annotatedElement.getClass() ) ?
( (XClass) annotatedElement ).getName() :
( (XPackage) annotatedElement ).getName();
- throw new AnnotationException( "@AnyMetaDef.name cannot be null on an entity or a package: " + name);
+ throw new AnnotationException( "@AnyMetaDef.name cannot be null on an entity or a package: " + name );
}
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ClassPropertyHolder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ClassPropertyHolder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ClassPropertyHolder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -5,6 +5,7 @@
import java.util.Map;
import javax.persistence.JoinTable;
+import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.cfg.annotations.EntityBinder;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Join;
@@ -12,7 +13,6 @@
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table;
-import org.hibernate.annotations.common.reflection.XClass;
/**
* @author Emmanuel Bernard
@@ -83,7 +83,7 @@
private Map<String, Join> getJoinsPerRealTableName() {
if ( joinsPerRealTableName == null ) {
joinsPerRealTableName = new HashMap<String, Join>( joins.size() );
- for ( Join join : joins.values() ) {
+ for (Join join : joins.values()) {
joinsPerRealTableName.put( join.getTable().getName(), join );
}
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/CollectionPropertyHolder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/CollectionPropertyHolder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/CollectionPropertyHolder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -4,14 +4,14 @@
import javax.persistence.JoinTable;
import org.hibernate.AssertionFailure;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XProperty;
/**
* @author Emmanuel Bernard
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ComponentPropertyHolder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ComponentPropertyHolder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ComponentPropertyHolder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -7,11 +7,11 @@
import org.hibernate.AnnotationException;
import org.hibernate.mapping.Component;
+import org.hibernate.mapping.Join;
import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table;
-import org.hibernate.mapping.Join;
/**
* Component implementation of property holder
@@ -35,7 +35,7 @@
* if a property is set already the core cannot support that
*/
Table table = columns[0].getTable();
- if ( ! table.equals( component.getTable() ) ) {
+ if ( !table.equals( component.getTable() ) ) {
if ( component.getPropertySpan() == 0 ) {
component.setTable( table );
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3Column.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3Column.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3Column.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -323,7 +323,7 @@
formulaColumn.setMappings( mappings );
formulaColumn.setPropertyHolder( propertyHolder );
formulaColumn.bind();
- columns = new Ejb3Column[]{formulaColumn};
+ columns = new Ejb3Column[] { formulaColumn };
}
else {
javax.persistence.Column[] actualCols = anns;
@@ -344,7 +344,7 @@
else {
final int length = actualCols.length;
columns = new Ejb3Column[length];
- for ( int index = 0; index < length ; index++ ) {
+ for (int index = 0; index < length; index++) {
javax.persistence.Column col = actualCols[index];
String sqlType = col.columnDefinition().equals( "" ) ? null : col.columnDefinition();
Ejb3Column column = new Ejb3Column();
@@ -386,7 +386,7 @@
//not following the spec but more clean
if ( nullability != Nullability.FORCED_NULL
&& inferredData.getClassOrElement().isPrimitive()
- && ! inferredData.getProperty().isArray() ) {
+ && !inferredData.getProperty().isArray() ) {
column.setNullable( false );
}
column.setLength( DEFAULT_COLUMN_LENGTH );
@@ -404,7 +404,7 @@
public static void checkPropertyConsistency(Ejb3Column[] columns, String propertyName) {
int nbrOfColumns = columns.length;
if ( nbrOfColumns > 1 ) {
- for ( int currentIndex = 1; currentIndex < nbrOfColumns ; currentIndex++ ) {
+ for (int currentIndex = 1; currentIndex < nbrOfColumns; currentIndex++) {
if ( columns[currentIndex].isInsertable() != columns[currentIndex - 1].isInsertable() ) {
throw new AnnotationException(
"Mixing insertable and non insertable columns in a property is not allowed: " + propertyName
@@ -420,7 +420,7 @@
"Mixing updatable and non updatable columns in a property is not allowed: " + propertyName
);
}
- if ( ! columns[currentIndex].getTable().equals( columns[currentIndex - 1].getTable() ) ) {
+ if ( !columns[currentIndex].getTable().equals( columns[currentIndex - 1].getTable() ) ) {
throw new AnnotationException(
"Mixing different tables in a property is not allowed: " + propertyName
);
@@ -432,12 +432,12 @@
public void addIndex(Index index, boolean inSecondPass) {
if ( index == null ) return;
String indexName = index.name();
- addIndex(indexName, inSecondPass);
+ addIndex( indexName, inSecondPass );
}
void addIndex(String indexName, boolean inSecondPass) {
IndexOrUniqueKeySecondPass secondPass = new IndexOrUniqueKeySecondPass( indexName, this, mappings, false );
- if (inSecondPass) {
+ if ( inSecondPass ) {
secondPass.doSecondPass( mappings.getClasses() );
}
else {
@@ -449,7 +449,7 @@
void addUniqueKey(String uniqueKeyName, boolean inSecondPass) {
IndexOrUniqueKeySecondPass secondPass = new IndexOrUniqueKeySecondPass( uniqueKeyName, this, mappings, true );
- if (inSecondPass) {
+ if ( inSecondPass ) {
secondPass.doSecondPass( mappings.getClasses() );
}
else {
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3DiscriminatorColumn.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3DiscriminatorColumn.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3DiscriminatorColumn.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -51,12 +51,12 @@
}
else if ( discAnn != null ) {
discriminatorColumn.setImplicit( false );
- if ( ! BinderHelper.isDefault( discAnn.columnDefinition() ) ) {
+ if ( !BinderHelper.isDefault( discAnn.columnDefinition() ) ) {
discriminatorColumn.setSqlType(
discAnn.columnDefinition()
);
}
- if ( ! BinderHelper.isDefault( discAnn.name() ) ) {
+ if ( !BinderHelper.isDefault( discAnn.name() ) ) {
discriminatorColumn.setLogicalColumnName( discAnn.name() );
}
discriminatorColumn.setNullable( false );
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3JoinColumn.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3JoinColumn.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3JoinColumn.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -116,14 +116,14 @@
);
if ( actualColumns == null ) actualColumns = anns;
if ( actualColumns == null || actualColumns.length == 0 ) {
- return new Ejb3JoinColumn[]{
+ return new Ejb3JoinColumn[] {
buildJoinColumn( (JoinColumn) null, mappedBy, joins, propertyHolder, propertyName, mappings )
};
}
else {
int size = actualColumns.length;
- Ejb3JoinColumn[] result = new Ejb3JoinColumn[ size ];
- for ( int index = 0; index < size ; index++ ) {
+ Ejb3JoinColumn[] result = new Ejb3JoinColumn[size];
+ for (int index = 0; index < size; index++) {
result[index] = buildJoinColumn(
actualColumns[index],
mappedBy,
@@ -185,8 +185,8 @@
}
else {
setImplicit( false );
- if ( ! BinderHelper.isDefault( annJoin.columnDefinition() ) ) setSqlType( annJoin.columnDefinition() );
- if ( ! BinderHelper.isDefault( annJoin.name() ) ) setLogicalColumnName( annJoin.name() );
+ if ( !BinderHelper.isDefault( annJoin.columnDefinition() ) ) setSqlType( annJoin.columnDefinition() );
+ if ( !BinderHelper.isDefault( annJoin.name() ) ) setLogicalColumnName( annJoin.name() );
setNullable( annJoin.nullable() );
setUnique( annJoin.unique() );
setInsertable( annJoin.insertable() );
@@ -253,7 +253,7 @@
}
public static void checkIfJoinColumn(Object columns, PropertyHolder holder, PropertyData property) {
- if ( ! ( columns instanceof Ejb3JoinColumn[] ) ) {
+ if ( !( columns instanceof Ejb3JoinColumn[] ) ) {
throw new AnnotationException(
"@Column cannot be used on an association property: "
+ holder.getEntityName()
@@ -401,7 +401,7 @@
( (PersistentClass) columnOwner ).getTable() :
( (Join) columnOwner ).getTable();
//check each referenced column
- for ( Ejb3JoinColumn ejb3Column : columns ) {
+ for (Ejb3JoinColumn ejb3Column : columns) {
String logicalReferencedColumnName = ejb3Column.getReferencedColumn();
if ( StringHelper.isNotEmpty( logicalReferencedColumnName ) ) {
String referencedColumnName = null;
@@ -418,7 +418,7 @@
noReferencedColumn = false;
Column refCol = new Column( referencedColumnName );
boolean contains = idColumns.contains( refCol );
- if ( ! contains ) {
+ if ( !contains ) {
isFkReferencedColumnName = true;
break; //we know the state
}
@@ -433,7 +433,8 @@
else if ( idColumns.size() != columns.length ) {
//reference use PK but is a subset or a superset
return NON_PK_REFERENCE;
- } else {
+ }
+ else {
return PK_REFERENCE;
}
}
@@ -474,7 +475,7 @@
currentJoinColumn.setMappedBy( mappedBy );
currentJoinColumn.bind();
- joinColumns = new Ejb3JoinColumn[]{
+ joinColumns = new Ejb3JoinColumn[] {
currentJoinColumn
};
@@ -483,7 +484,7 @@
joinColumns = new Ejb3JoinColumn[annJoins.length];
JoinColumn annJoin;
int length = annJoins.length;
- for ( int index = 0; index < length ; index++ ) {
+ for (int index = 0; index < length; index++) {
annJoin = annJoins[index];
Ejb3JoinColumn currentJoinColumn = new Ejb3JoinColumn();
currentJoinColumn.setImplicit( true );
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ExtendedMappings.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ExtendedMappings.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ExtendedMappings.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -12,8 +12,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
-import org.hibernate.AnnotationException;
+import org.hibernate.annotations.AnyMetaDef;
+import org.hibernate.annotations.common.reflection.ReflectionManager;
+import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.engine.NamedQueryDefinition;
import org.hibernate.engine.NamedSQLQueryDefinition;
import org.hibernate.engine.ResultSetMappingDefinition;
@@ -21,9 +24,6 @@
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.AnyMetaDef;
/**
* Allow annotation related mappings
@@ -53,7 +53,7 @@
ExtendedMappings(
Map classes, Map collections, Map tables, Map queries, Map sqlqueries, Map sqlResultSetMappings,
Set<String> defaultNamedQueryNames, Set<String> defaultNamedNativeQueryNames,
- Set<String> defaultSqlResulSetMappingNames, Set<String> defaultNamedGenerators, Map imports,
+ Set<String> defaultSqlResulSetMappingNames, Set<String> defaultNamedGenerators, Map imports,
List secondPasses, List propertyReferences, NamingStrategy namingStrategy, Map typeDefs,
Map filterDefinitions, Map namedGenerators, Map<String, Map<String, Join>> joins, Map<String,
AnnotatedClassType> classTypes, Map extendsQueue, Map<String, TableDescription> tableNameBinding,
@@ -100,7 +100,7 @@
}
public void addGenerator(IdGenerator generator) throws MappingException {
- if ( ! defaultNamedGenerators.contains( generator.getName() ) ) {
+ if ( !defaultNamedGenerators.contains( generator.getName() ) ) {
Object old = namedGenerators.put( generator.getName(), generator );
if ( old != null ) log.warn( "duplicate generator name: " + generator.getName() );
}
@@ -224,45 +224,45 @@
}
public void addDefaultQuery(String name, NamedQueryDefinition query) {
- super.addQuery(name, query);
+ super.addQuery( name, query );
defaultNamedQueryNames.add( name );
}
public void addDefaultSQLQuery(String name, NamedSQLQueryDefinition query) {
- super.addSQLQuery(name, query);
+ super.addSQLQuery( name, query );
defaultNamedNativeQueryNames.add( name );
}
public void addDefaultGenerator(IdGenerator idGen) {
- this.addGenerator(idGen);
+ this.addGenerator( idGen );
defaultNamedGenerators.add( idGen.getName() );
}
public void addDefaultResultSetMapping(ResultSetMappingDefinition definition) {
final String name = definition.getName();
- if ( ! defaultSqlResulSetMappingNames.contains( name )
+ if ( !defaultSqlResulSetMappingNames.contains( name )
&& super.getResultSetMapping( name ) != null ) {
resultSetMappings.remove( name );
}
- super.addResultSetMapping(definition);
+ super.addResultSetMapping( definition );
defaultSqlResulSetMappingNames.add( name );
}
@Override
public void addQuery(String name, NamedQueryDefinition query) throws MappingException {
- if ( ! defaultNamedQueryNames.contains( name ) ) super.addQuery( name, query );
+ if ( !defaultNamedQueryNames.contains( name ) ) super.addQuery( name, query );
}
@Override
public void addResultSetMapping(ResultSetMappingDefinition definition) {
- if ( ! defaultSqlResulSetMappingNames.contains( definition.getName() ) )
+ if ( !defaultSqlResulSetMappingNames.contains( definition.getName() ) )
super.addResultSetMapping( definition );
}
@Override
public void addSQLQuery(String name, NamedSQLQueryDefinition query) throws MappingException {
- if ( ! defaultNamedNativeQueryNames.contains( name ) ) super.addSQLQuery( name, query );
+ if ( !defaultNamedNativeQueryNames.contains( name ) ) super.addSQLQuery( name, query );
}
public Map getClasses() {
@@ -271,7 +271,7 @@
public void addAnyMetaDef(AnyMetaDef defAnn) {
if ( anyMetaDefs.containsKey( defAnn.name() ) ) {
- throw new AnnotationException("Two @AnyMetaDef with the same name defined: " + defAnn.name() );
+ throw new AnnotationException( "Two @AnyMetaDef with the same name defined: " + defAnn.name() );
}
anyMetaDefs.put( defAnn.name(), defAnn );
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/FkSecondPass.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/FkSecondPass.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/FkSecondPass.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -1,9 +1,8 @@
-//$Id$
+//$Id: FkSecondPass.java 11650 2007-06-07 16:44:52Z epbernard $
package org.hibernate.cfg;
-import org.hibernate.mapping.Value;
-import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.Value;
/**
* @author Emmanuel Bernard
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -35,14 +35,14 @@
* Build an index
*/
public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column, ExtendedMappings mappings) {
- this(indexName, column, mappings, false);
+ this( indexName, column, mappings, false );
}
/**
* Build an index if unique is false or a Unique Key if unique is true
*/
public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column,
- ExtendedMappings mappings, boolean unique) {
+ ExtendedMappings mappings, boolean unique) {
this.indexName = indexName;
this.column = column;
this.columns = null;
@@ -52,7 +52,7 @@
public void doSecondPass(Map persistentClasses) throws MappingException {
if ( columns != null ) {
- for ( String columnName : columns ) {
+ for (String columnName : columns) {
addConstraintToColumn( columnName );
}
}
@@ -73,7 +73,7 @@
"@Index references a unknown column: " + columnName
);
}
- if(unique)
+ if ( unique )
table.getOrCreateUniqueKey( indexName ).addColumn( column );
else
table.getOrCreateIndex( indexName ).addColumn( column );
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/InheritanceState.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/InheritanceState.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/InheritanceState.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -68,9 +68,9 @@
do {
superclass = superclass.getSuperclass();
InheritanceState currentState = states.get( superclass );
- if ( currentState != null && ! currentState.isEmbeddableSuperclass ) return currentState;
+ if ( currentState != null && !currentState.isEmbeddableSuperclass ) return currentState;
}
- while ( superclass != null && ! reflectionManager.equals( superclass, Object.class ) );
+ while ( superclass != null && !reflectionManager.equals( superclass, Object.class ) );
return null;
}
@@ -84,7 +84,7 @@
InheritanceState currentState = states.get( superclass );
if ( currentState != null ) return currentState;
}
- while ( superclass != null && ! reflectionManager.equals( superclass, Object.class ) );
+ while ( superclass != null && !reflectionManager.equals( superclass, Object.class ) );
return null;
}
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/JoinedSubclassFkSecondPass.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/JoinedSubclassFkSecondPass.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/JoinedSubclassFkSecondPass.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -5,8 +5,6 @@
import org.hibernate.MappingException;
import org.hibernate.cfg.annotations.TableBinder;
-import org.hibernate.mapping.Value;
-import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.JoinedSubclass;
import org.hibernate.mapping.SimpleValue;
@@ -18,11 +16,11 @@
private ExtendedMappings mappings;
public JoinedSubclassFkSecondPass(JoinedSubclass entity, Ejb3JoinColumn[] inheritanceJoinedColumns, SimpleValue key, ExtendedMappings mappings) {
- super(key, inheritanceJoinedColumns);
+ super( key, inheritanceJoinedColumns );
this.entity = entity;
this.mappings = mappings;
}
-
+
public String getReferencedEntityName() {
return entity.getSuperclass().getEntityName();
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/OneToOneSecondPass.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -7,6 +7,7 @@
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.annotations.ForeignKey;
+import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.cfg.annotations.PropertyBinder;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.DependantValue;
@@ -16,7 +17,6 @@
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.SimpleValue;
-import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.type.ForeignKeyDirection;
import org.hibernate.util.StringHelper;
@@ -100,7 +100,7 @@
*/
boolean rightOrder = true;
- if (rightOrder) {
+ if ( rightOrder ) {
String path = StringHelper.qualify( propertyHolder.getPath(), propertyName );
( new ToOneFkSecondPass(
value, joinColumns,
@@ -132,7 +132,7 @@
+ StringHelper.qualify( value.getReferencedEntityName(), mappedBy )
);
}
- if (otherSideProperty == null) {
+ if ( otherSideProperty == null ) {
throw new AnnotationException(
"Unknown mappedBy in: " + StringHelper.qualify( ownerEntity, ownerProperty )
+ ", referenced property unknown: "
@@ -212,7 +212,7 @@
}
ForeignKey fk = inferredData.getProperty().getAnnotation( ForeignKey.class );
String fkName = fk != null ? fk.name() : "";
- if ( ! BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName );
+ if ( !BinderHelper.isDefault( fkName ) ) value.setForeignKeyName( fkName );
}
//dirty dupe of EntityBinder.bindSecondaryTable
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -4,11 +4,11 @@
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
+import org.hibernate.mapping.Join;
import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table;
-import org.hibernate.mapping.Join;
/**
* Property holder abstract property containers from their direct implementation
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolderBuilder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolderBuilder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyHolderBuilder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -3,13 +3,13 @@
import java.util.Map;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.annotations.EntityBinder;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XProperty;
/**
* This factory is here ot build a PropertyHolder and prevent .mapping interface adding
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyInferredData.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyInferredData.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/PropertyInferredData.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -4,9 +4,9 @@
import org.hibernate.MappingException;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.Target;
+import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
/**
* Retrieve all inferred data from an annnoted element
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ToOneFkSecondPass.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ToOneFkSecondPass.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/ToOneFkSecondPass.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -4,14 +4,13 @@
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
-import org.hibernate.util.StringHelper;
import org.hibernate.cfg.annotations.TableBinder;
import org.hibernate.mapping.ManyToOne;
import org.hibernate.mapping.OneToOne;
import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Property;
-import org.hibernate.mapping.Value;
+import org.hibernate.mapping.ToOne;
+import org.hibernate.util.StringHelper;
/**
* Enable a proper set of the FK columns in respect with the id column order
@@ -37,11 +36,11 @@
}
public String getReferencedEntityName() {
- return ((ToOne) value).getReferencedEntityName();
+ return ( (ToOne) value ).getReferencedEntityName();
}
public boolean isInPrimaryKey() {
- if (entityClassName == null) return false;
+ if ( entityClassName == null ) return false;
Property property = mappings.getClass( entityClassName ).getIdentifierProperty();
return property != null && path != null && path.startsWith( property.getName() );
}
@@ -53,7 +52,7 @@
if ( ref == null ) {
throw new AnnotationException(
"@OneToOne or @ManyToOne on "
- + StringHelper.qualify(entityClassName, path)
+ + StringHelper.qualify( entityClassName, path )
+ " references an unknown entity: "
+ manyToOne.getReferencedEntityName()
);
@@ -63,7 +62,7 @@
/*
* HbmBinder does this only when property-ref != null, but IMO, it makes sense event if it is null
*/
- if ( ! manyToOne.isIgnoreNotFound() ) manyToOne.createPropertyRefConstraints( persistentClasses );
+ if ( !manyToOne.isIgnoreNotFound() ) manyToOne.createPropertyRefConstraints( persistentClasses );
}
else if ( value instanceof OneToOne ) {
( (OneToOne) value ).createForeignKey();
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/WrappedInferredData.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/WrappedInferredData.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/WrappedInferredData.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -1,9 +1,9 @@
//$Id: $
package org.hibernate.cfg;
+import org.hibernate.MappingException;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
-import org.hibernate.MappingException;
import org.hibernate.util.StringHelper;
/**
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -22,7 +22,6 @@
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
-import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CollectionId;
@@ -33,22 +32,24 @@
import org.hibernate.annotations.FilterJoinTables;
import org.hibernate.annotations.Filters;
import org.hibernate.annotations.ForeignKey;
+import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
+import org.hibernate.annotations.Loader;
+import org.hibernate.annotations.ManyToAny;
+import org.hibernate.annotations.OptimisticLock;
import org.hibernate.annotations.OrderBy;
+import org.hibernate.annotations.Persister;
+import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.SQLDeleteAll;
+import org.hibernate.annotations.SQLInsert;
+import org.hibernate.annotations.SQLUpdate;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortType;
import org.hibernate.annotations.Where;
import org.hibernate.annotations.WhereJoinTable;
-import org.hibernate.annotations.SQLInsert;
-import org.hibernate.annotations.SQLUpdate;
-import org.hibernate.annotations.SQLDelete;
-import org.hibernate.annotations.SQLDeleteAll;
-import org.hibernate.annotations.Loader;
-import org.hibernate.annotations.Immutable;
-import org.hibernate.annotations.OptimisticLock;
-import org.hibernate.annotations.Persister;
-import org.hibernate.annotations.ManyToAny;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.AnnotatedClassType;
import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.BinderHelper;
@@ -60,9 +61,11 @@
import org.hibernate.cfg.PropertyData;
import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.PropertyHolderBuilder;
+import org.hibernate.cfg.PropertyInferredData;
import org.hibernate.cfg.PropertyPreloadedData;
import org.hibernate.cfg.SecondPass;
-import org.hibernate.cfg.PropertyInferredData;
+import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
+import org.hibernate.mapping.Any;
import org.hibernate.mapping.Backref;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
@@ -77,9 +80,6 @@
import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
-import org.hibernate.mapping.Any;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.util.StringHelper;
/**
@@ -171,13 +171,13 @@
public void setSqlOrderBy(OrderBy orderByAnn) {
if ( orderByAnn != null ) {
- if ( ! BinderHelper.isDefault( orderByAnn.clause() ) ) orderBy = orderByAnn.clause();
+ if ( !BinderHelper.isDefault( orderByAnn.clause() ) ) orderBy = orderByAnn.clause();
}
}
public void setSort(Sort sortAnn) {
if ( sortAnn != null ) {
- isSorted = ! SortType.UNSORTED.equals( sortAnn.type() );
+ isSorted = !SortType.UNSORTED.equals( sortAnn.type() );
if ( isSorted && SortType.COMPARATOR.equals( sortAnn.type() ) ) {
comparator = sortAnn.comparator();
}
@@ -212,7 +212,7 @@
return new MapBinder();
}
else if ( java.util.SortedMap.class.equals( returnedClass ) ) {
- return new MapBinder(true);
+ return new MapBinder( true );
}
else if ( java.util.Collection.class.equals( returnedClass ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) {
@@ -309,11 +309,11 @@
);
}
- collection.setMutable( ! property.isAnnotationPresent( Immutable.class ) );
+ collection.setMutable( !property.isAnnotationPresent( Immutable.class ) );
OptimisticLock lockAnn = property.getAnnotation( OptimisticLock.class );
- if (lockAnn != null) collection.setOptimisticLocked( ! lockAnn.excluded() );
+ if ( lockAnn != null ) collection.setOptimisticLocked( !lockAnn.excluded() );
Persister persisterAnn = property.getAnnotation( Persister.class );
- if ( persisterAnn != null ) collection.setCollectionPersisterClass( persisterAnn.impl() );
+ if ( persisterAnn != null ) collection.setCollectionPersisterClass( persisterAnn.impl() );
// set ordering
if ( orderBy != null ) collection.setOrderBy( orderBy );
@@ -384,11 +384,11 @@
}
//work on association
- boolean isMappedBy = ! BinderHelper.isDefault( mappedBy );
+ boolean isMappedBy = !BinderHelper.isDefault( mappedBy );
collection.setInverse( isMappedBy );
-
+
//many to many may need some second pass informations
- if ( ! oneToMany && isMappedBy ) {
+ if ( !oneToMany && isMappedBy ) {
mappings.addMappedBy( getCollectionType().getName(), mappedBy, propertyName );
}
//TODO reducce tableBinder != null and oneToMany
@@ -408,10 +408,10 @@
// do it right away, otherwise @ManyToon on composite element call addSecondPass
// and raise a ConcurrentModificationException
//sp.doSecondPass( CollectionHelper.EMPTY_MAP );
- mappings.addSecondPass( sp, ! isMappedBy );
+ mappings.addSecondPass( sp, !isMappedBy );
}
else {
- mappings.addSecondPass( sp, ! isMappedBy );
+ mappings.addSecondPass( sp, !isMappedBy );
}
mappings.addCollection( collection );
@@ -459,7 +459,7 @@
);
}
if ( lazy != null ) {
- collection.setLazy( ! ( lazy.value() == LazyCollectionOption.FALSE ) );
+ collection.setLazy( !( lazy.value() == LazyCollectionOption.FALSE ) );
collection.setExtraLazy( lazy.value() == LazyCollectionOption.EXTRA );
}
else {
@@ -557,11 +557,11 @@
}
}
if ( persistentClass != null
- && ! reversePropertyInJoin
+ && !reversePropertyInJoin
&& oneToMany
- && ! this.isExplicitAssociationTable
- && ( joinColumns[0].isImplicit() && ! BinderHelper.isDefault( this.mappedBy ) //implicit @JoinColumn
- || ! fkJoinColumns[0].isImplicit() ) //this is an explicit @JoinColumn
+ && !this.isExplicitAssociationTable
+ && ( joinColumns[0].isImplicit() && !BinderHelper.isDefault( this.mappedBy ) //implicit @JoinColumn
+ || !fkJoinColumns[0].isImplicit() ) //this is an explicit @JoinColumn
) {
//this is a Foreign key
bindOneToManySecondPass(
@@ -594,7 +594,7 @@
protected void bindOneToManySecondPass(
Collection collection, Map persistentClasses, Ejb3JoinColumn[] fkJoinColumns,
- XClass collectionType,
+ XClass collectionType,
boolean cascadeDeleteEnabled, boolean ignoreNotFound, String hqlOrderBy, ExtendedMappings extendedMappings
) {
if ( log.isDebugEnabled() ) {
@@ -623,7 +623,7 @@
);
}
oneToMany.setAssociatedClass( associatedClass );
- for ( Ejb3JoinColumn column : fkJoinColumns ) {
+ for (Ejb3JoinColumn column : fkJoinColumns) {
column.setPersistentClass( associatedClass, joins );
column.setJoins( joins );
collection.setCollectionTable( column.getTable() );
@@ -631,7 +631,7 @@
log.info(
"Mapping collection: " + collection.getRole() + " -> " + collection.getCollectionTable().getName()
);
- bindFilters(false);
+ bindFilters( false );
bindCollectionSecondPass( collection, null, fkJoinColumns, cascadeDeleteEnabled, property, mappings );
if ( !collection.isInverse()
&& !collection.getKey().isNullable() ) {
@@ -649,15 +649,14 @@
}
}
-
private void bindFilters(boolean hasAssociationTable) {
Filter simpleFilter = property.getAnnotation( Filter.class );
//set filtering
//test incompatible choices
//if ( StringHelper.isNotEmpty( where ) ) collection.setWhere( where );
- if (simpleFilter != null) {
- if (hasAssociationTable) {
+ if ( simpleFilter != null ) {
+ if ( hasAssociationTable ) {
collection.addManyToManyFilter( simpleFilter.name(), getCondition( simpleFilter ) );
}
else {
@@ -665,9 +664,9 @@
}
}
Filters filters = property.getAnnotation( Filters.class );
- if (filters != null) {
- for ( Filter filter : filters.value() ) {
- if (hasAssociationTable) {
+ if ( filters != null ) {
+ for (Filter filter : filters.value()) {
+ if ( hasAssociationTable ) {
collection.addManyToManyFilter( filter.name(), getCondition( filter ) );
}
else {
@@ -676,8 +675,8 @@
}
}
FilterJoinTable simpleFilterJoinTable = property.getAnnotation( FilterJoinTable.class );
- if (simpleFilterJoinTable != null) {
- if (hasAssociationTable) {
+ if ( simpleFilterJoinTable != null ) {
+ if ( hasAssociationTable ) {
collection.addFilter( simpleFilterJoinTable.name(), getCondition( simpleFilterJoinTable ) );
}
else {
@@ -688,9 +687,9 @@
}
}
FilterJoinTables filterJoinTables = property.getAnnotation( FilterJoinTables.class );
- if (filterJoinTables != null) {
- for ( FilterJoinTable filter : filterJoinTables.value() ) {
- if (hasAssociationTable) {
+ if ( filterJoinTables != null ) {
+ for (FilterJoinTable filter : filterJoinTables.value()) {
+ if ( hasAssociationTable ) {
collection.addFilter( filter.name(), getCondition( filter ) );
}
else {
@@ -705,7 +704,7 @@
Where where = property.getAnnotation( Where.class );
String whereClause = where == null ? null : where.clause();
if ( StringHelper.isNotEmpty( whereClause ) ) {
- if (hasAssociationTable) {
+ if ( hasAssociationTable ) {
collection.setManyToManyWhere( whereClause );
}
else {
@@ -716,7 +715,7 @@
WhereJoinTable whereJoinTable = property.getAnnotation( WhereJoinTable.class );
String whereJoinTableClause = whereJoinTable == null ? null : whereJoinTable.clause();
if ( StringHelper.isNotEmpty( whereJoinTableClause ) ) {
- if (hasAssociationTable) {
+ if ( hasAssociationTable ) {
collection.setWhere( whereJoinTableClause );
}
else {
@@ -843,7 +842,7 @@
}
int index = 0;
- for ( String property : properties ) {
+ for (String property : properties) {
Property p = BinderHelper.findPropertyByName( associatedClass, property );
if ( p == null ) {
throw new AnnotationException(
@@ -853,13 +852,13 @@
}
PersistentClass pc = p.getPersistentClass();
String table;
- if (pc == null) {
+ if ( pc == null ) {
//we are touching a @IdClass property, the pc is not set
//this means pc == associatedClass
//TODO check whether @ManyToOne @JoinTable in @IdClass used for @OrderBy works: doh!
table = "";
}
- else if (pc != associatedClass) {
+ else if ( pc != associatedClass ) {
table = pc.getTable().getQuotedName() + ".";
}
else {
@@ -931,7 +930,7 @@
}
int index = 0;
- for ( String property : properties ) {
+ for (String property : properties) {
Property p = component.getProperty( property );
if ( p == null ) {
throw new AnnotationException(
@@ -1006,7 +1005,7 @@
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.isDefault( fkName ) ) key.setForeignKeyName( fkName );
return key;
}
@@ -1017,7 +1016,7 @@
Ejb3JoinColumn[] inverseJoinColumns,
Ejb3Column[] elementColumns,
boolean isEmbedded,
- XClass collType,
+ XClass collType,
boolean ignoreNotFound, boolean unique,
boolean cascadeDeleteEnabled,
TableBinder associationTableBinder, XProperty property, PropertyHolder parentPropertyHolder,
@@ -1043,7 +1042,7 @@
}
}
//check for user error
- if ( ! isCollectionOfEntities ) {
+ if ( !isCollectionOfEntities ) {
if ( property.isAnnotationPresent( ManyToMany.class ) || property.isAnnotationPresent( OneToMany.class ) ) {
String path = collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName();
throw new AnnotationException(
@@ -1051,7 +1050,7 @@
);
}
else if ( anyAnn != null ) {
- if (! property.isAnnotationPresent( JoinTable.class ) ) {
+ if ( !property.isAnnotationPresent( JoinTable.class ) ) {
String path = collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName();
throw new AnnotationException(
"@JoinTable is mandatory when @ManyToAny is used: " + path
@@ -1069,9 +1068,9 @@
}
}
- boolean mappedBy = ! BinderHelper.isDefault( joinColumns[0].getMappedBy() );
+ boolean mappedBy = !BinderHelper.isDefault( joinColumns[0].getMappedBy() );
if ( mappedBy ) {
- if ( ! isCollectionOfEntities ) {
+ if ( !isCollectionOfEntities ) {
StringBuilder error = new StringBuilder( 80 )
.append(
"Collection of elements must not have mappedBy or association reference an unmapped entity: "
@@ -1106,7 +1105,7 @@
}
collValue.setCollectionTable( table );
String entityName = collectionEntity.getEntityName();
- for ( Ejb3JoinColumn column : joinColumns ) {
+ for (Ejb3JoinColumn column : joinColumns) {
//column.setDefaultColumnHeader( joinColumns[0].getMappedBy() ); //seems not to be used, make sense
column.setManyToManyOwnerSideEntityName( entityName );
}
@@ -1114,7 +1113,7 @@
else {
//TODO: only for implicit columns?
//FIXME NamingStrategy
- for ( Ejb3JoinColumn column : joinColumns ) {
+ for (Ejb3JoinColumn column : joinColumns) {
String mappedByProperty = mappings.getFromMappedBy(
collValue.getOwnerEntityName(), column.getPropertyName()
);
@@ -1160,14 +1159,14 @@
}
ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null;
String fkName = fk != null ? fk.inverseName() : "";
- if ( ! BinderHelper.isDefault( fkName ) ) element.setForeignKeyName( fkName );
+ if ( !BinderHelper.isDefault( fkName ) ) element.setForeignKeyName( fkName );
}
else if ( anyAnn != null ) {
//@ManyToAny
//Make sure that collTyp is never used during the @ManyToAny branch: it will be set to void.class
- PropertyData inferredData = new PropertyInferredData(property, "unsupported", mappings.getReflectionManager() );
+ PropertyData inferredData = new PropertyInferredData( property, "unsupported", mappings.getReflectionManager() );
//override the table
- for ( Ejb3Column column : inverseJoinColumns ) {
+ for (Ejb3Column column : inverseJoinColumns) {
column.setTable( collValue.getCollectionTable() );
}
Any any = BinderHelper.buildAnyValue( anyAnn.metaDef(), inverseJoinColumns, anyAnn.metaColumn(),
@@ -1260,7 +1259,7 @@
elementColumns[0] = column;
}
//override the table
- for ( Ejb3Column column : elementColumns ) {
+ for (Ejb3Column column : elementColumns) {
column.setTable( collValue.getCollectionTable() );
}
elementBinder.setColumns( elementColumns );
@@ -1282,7 +1281,7 @@
//for now it can't happen, but sometime soon...
if ( ( collValue.getFilterMap().size() != 0 || StringHelper.isNotEmpty( collValue.getWhere() ) ) &&
collValue.getFetchMode() == FetchMode.JOIN &&
- ! (collValue.getElement() instanceof SimpleValue) && //SimpleValue (CollectionOfElements) are always SELECT but it does not matter
+ !( collValue.getElement() instanceof SimpleValue ) && //SimpleValue (CollectionOfElements) are always SELECT but it does not matter
collValue.getElement().getFetchMode() != FetchMode.JOIN ) {
throw new MappingException(
"@ManyToMany or @CollectionOfElements defining filter or where without join fetching "
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -18,28 +18,30 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
+import org.hibernate.EntityMode;
import org.hibernate.MappingException;
-import org.hibernate.EntityMode;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
+import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.ForceDiscriminator;
+import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Loader;
import org.hibernate.annotations.OptimisticLockType;
+import org.hibernate.annotations.Persister;
import org.hibernate.annotations.PolymorphismType;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.SQLInsert;
import org.hibernate.annotations.SQLUpdate;
import org.hibernate.annotations.Tables;
+import org.hibernate.annotations.Tuplizer;
+import org.hibernate.annotations.Tuplizers;
import org.hibernate.annotations.Where;
-import org.hibernate.annotations.SQLDeleteAll;
-import org.hibernate.annotations.Tuplizers;
-import org.hibernate.annotations.Tuplizer;
-import org.hibernate.annotations.Immutable;
-import org.hibernate.annotations.FetchMode;
-import org.hibernate.annotations.Persister;
+import org.hibernate.annotations.common.reflection.XAnnotatedElement;
+import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.cache.CacheFactory;
import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.BinderHelper;
@@ -47,9 +49,9 @@
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.InheritanceState;
import org.hibernate.cfg.PropertyHolder;
-import org.hibernate.engine.Versioning;
import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
import org.hibernate.engine.FilterDefinition;
+import org.hibernate.engine.Versioning;
import org.hibernate.mapping.DependantValue;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
@@ -58,8 +60,6 @@
import org.hibernate.mapping.Table;
import org.hibernate.mapping.TableOwner;
import org.hibernate.mapping.Value;
-import org.hibernate.annotations.common.reflection.XAnnotatedElement;
-import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
@@ -208,12 +208,12 @@
//@Persister has precedence over @Entity.persister
Persister persisterAnn = annotatedClass.getAnnotation( Persister.class );
Class persister = null;
- if ( persisterAnn!= null ) {
+ if ( persisterAnn != null ) {
persister = persisterAnn.impl();
}
else {
org.hibernate.annotations.Entity entityAnn = annotatedClass.getAnnotation( org.hibernate.annotations.Entity.class );
- if (entityAnn != null && !BinderHelper.isDefault( entityAnn.persister() ) ) {
+ if ( entityAnn != null && !BinderHelper.isDefault( entityAnn.persister() ) ) {
try {
persister = ReflectHelper.classForName( entityAnn.persister() );
}
@@ -222,7 +222,7 @@
}
}
}
- if ( persister != null ) persistentClass.setEntityPersisterClass(persister);
+ if ( persister != null ) persistentClass.setEntityPersisterClass( persister );
persistentClass.setBatchSize( batchSize );
@@ -259,7 +259,7 @@
//tuplizers
if ( annotatedClass.isAnnotationPresent( Tuplizers.class ) ) {
- for ( Tuplizer tuplizer : annotatedClass.getAnnotation( Tuplizers.class ).value() ) {
+ for (Tuplizer tuplizer : annotatedClass.getAnnotation( Tuplizers.class ).value()) {
EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
persistentClass.addTuplizer( mode, tuplizer.impl().getName() );
}
@@ -331,7 +331,7 @@
}
int getVersioning(OptimisticLockType type) {
- switch (type) {
+ switch ( type ) {
case VERSION:
return Versioning.OPTIMISTIC_LOCK_VERSION;
case NONE:
@@ -346,7 +346,7 @@
}
private boolean isExplicitPolymorphism(PolymorphismType type) {
- switch (type) {
+ switch ( type ) {
case IMPLICIT:
return false;
case EXPLICIT:
@@ -483,7 +483,7 @@
else {
ejb3JoinColumns = new Ejb3JoinColumn[nbrOfJoinColumns];
if ( pkColumnsAnn != null ) {
- for ( int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++ ) {
+ for (int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++) {
ejb3JoinColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn(
pkColumnsAnn[colIndex],
null,
@@ -494,7 +494,7 @@
}
}
else {
- for ( int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++ ) {
+ for (int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++) {
ejb3JoinColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn(
null,
joinColumnsAnn[colIndex],
@@ -507,7 +507,7 @@
}
}
- for ( Ejb3JoinColumn joinColumn : ejb3JoinColumns ) {
+ for (Ejb3JoinColumn joinColumn : ejb3JoinColumns) {
joinColumn.forceNotNull();
}
bindJoinToPersistentClass( join, ejb3JoinColumns );
@@ -518,7 +518,7 @@
) {
SimpleValue key = new DependantValue( join.getTable(), persistentClass.getIdentifier() );
join.setKey( key );
- setFKNameIfDefined(join);
+ setFKNameIfDefined( join );
key.setCascadeDeleteEnabled( false );
TableBinder.bindFk( persistentClass, null, ejb3JoinColumns, key, false, mappings );
join.createPrimaryKey();
@@ -528,7 +528,7 @@
private void setFKNameIfDefined(Join join) {
org.hibernate.annotations.Table matchingTable = findMatchingComplimentTableAnnotation( join );
- if (matchingTable != null && ! BinderHelper.isDefault( matchingTable.foreignKey().name() ) ) {
+ if ( matchingTable != null && !BinderHelper.isDefault( matchingTable.foreignKey().name() ) ) {
( (SimpleValue) join.getKey() ).setForeignKeyName( matchingTable.foreignKey().name() );
}
}
@@ -542,8 +542,8 @@
}
else {
Tables tables = annotatedClass.getAnnotation( Tables.class );
- if ( tables != null) {
- for (org.hibernate.annotations.Table current : tables.value() ) {
+ if ( tables != null ) {
+ for (org.hibernate.annotations.Table current : tables.value()) {
if ( tableName.equals( current.appliesTo() ) ) {
matchingTable = current;
break;
@@ -559,7 +559,7 @@
) {
if ( secTables != null ) {
//loop through it
- for ( SecondaryTable tab : secTables.value() ) {
+ for (SecondaryTable tab : secTables.value()) {
addJoin( tab, null, null, false );
}
}
@@ -608,7 +608,7 @@
0 :
uniqueConstraintsAnn.length );
if ( uniqueConstraintsAnn != null && uniqueConstraintsAnn.length != 0 ) {
- for ( UniqueConstraint uc : uniqueConstraintsAnn ) {
+ for (UniqueConstraint uc : uniqueConstraintsAnn) {
uniqueConstraints.add( uc.columnNames() );
}
}
@@ -639,23 +639,23 @@
}
org.hibernate.annotations.Table matchingTable = findMatchingComplimentTableAnnotation( join );
- if (matchingTable != null) {
+ if ( matchingTable != null ) {
join.setSequentialSelect( FetchMode.JOIN != matchingTable.fetch() );
join.setInverse( matchingTable.inverse() );
join.setOptional( matchingTable.optional() );
- if ( ! BinderHelper.isDefault( matchingTable.sqlInsert().sql() ) ) {
+ if ( !BinderHelper.isDefault( 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() ) ) {
- join.setCustomSQLUpdate( matchingTable.sqlUpdate().sql().trim(),
+ if ( !BinderHelper.isDefault( 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.isDefault( matchingTable.sqlDelete().sql() ) ) {
join.setCustomSQLDelete( matchingTable.sqlDelete().sql().trim(),
matchingTable.sqlDelete().callable(),
ExecuteUpdateResultCheckStyle.parse( matchingTable.sqlDelete().check().toString().toLowerCase() )
@@ -707,7 +707,7 @@
}
public static String getCacheConcurrencyStrategy(CacheConcurrencyStrategy strategy) {
- switch (strategy) {
+ switch ( strategy ) {
case NONE:
return null;
case READ_ONLY:
@@ -756,13 +756,13 @@
"@org.hibernate.annotations.Table references an unknown table: " + appliedTable
);
}
- if ( ! BinderHelper.isDefault( table.comment() ) ) hibTable.setComment( table.comment() );
+ if ( !BinderHelper.isDefault( table.comment() ) ) hibTable.setComment( table.comment() );
TableBinder.addIndexes( hibTable, table.indexes(), mappings );
}
public void processComplementaryTableDefinitions(Tables tables) {
if ( tables == null ) return;
- for ( org.hibernate.annotations.Table table : tables.value() ) {
+ for (org.hibernate.annotations.Table table : tables.value()) {
processComplementaryTableDefinitions( table );
}
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/IdBagBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/IdBagBinder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/IdBagBinder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -7,6 +7,8 @@
import org.hibernate.AnnotationException;
import org.hibernate.annotations.CollectionId;
import org.hibernate.annotations.Type;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.Ejb3JoinColumn;
@@ -19,8 +21,6 @@
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.util.StringHelper;
/**
@@ -42,11 +42,11 @@
property, unique, associationTableBinder, ignoreNotFound, mappings
);
CollectionId collectionIdAnn = property.getAnnotation( CollectionId.class );
- if (collectionIdAnn != null) {
+ if ( collectionIdAnn != null ) {
SimpleValueBinder simpleValue = new SimpleValueBinder();
PropertyData propertyData = new WrappedInferredData(
- new PropertyInferredData(property, null, //default access should not be useful
+ new PropertyInferredData( property, null, //default access should not be useful
mappings.getReflectionManager() ),
"id" );
Ejb3Column[] idColumns = Ejb3Column.buildColumnFromAnnotation(
@@ -62,11 +62,11 @@
simpleValue.setTable( table );
simpleValue.setColumns( idColumns );
Type typeAnn = collectionIdAnn.type();
- if ( typeAnn != null && ! BinderHelper.isDefault( typeAnn.type() ) ) {
+ if ( typeAnn != null && !BinderHelper.isDefault( typeAnn.type() ) ) {
simpleValue.setExplicitType( typeAnn );
}
else {
- throw new AnnotationException("@CollectionId is missing type: "
+ throw new AnnotationException( "@CollectionId is missing type: "
+ StringHelper.qualify( propertyHolder.getPath(), propertyName ) );
}
simpleValue.setMappings( mappings );
@@ -82,7 +82,7 @@
else {
generatorType = null;
}
- BinderHelper.makeIdGenerator( id, generatorType, generator, mappings, localGenerators);
+ BinderHelper.makeIdGenerator( id, generatorType, generator, mappings, localGenerators );
}
return result;
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/ListBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/ListBinder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/ListBinder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -6,9 +6,10 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
-import org.hibernate.util.StringHelper;
import org.hibernate.annotations.OrderBy;
import org.hibernate.annotations.Sort;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.CollectionSecondPass;
import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.Ejb3JoinColumn;
@@ -22,8 +23,7 @@
import org.hibernate.mapping.OneToMany;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.util.StringHelper;
/**
* Bind a list
@@ -80,10 +80,10 @@
(XProperty) null, propertyHolder, mappings
);
List list = (List) this.collection;
- if ( ! list.isOneToMany() ) indexColumn.forceNotNull();
+ if ( !list.isOneToMany() ) indexColumn.forceNotNull();
indexColumn.setPropertyHolder( valueHolder );
SimpleValueBinder value = new SimpleValueBinder();
- value.setColumns( new Ejb3Column[]{indexColumn} );
+ value.setColumns( new Ejb3Column[] { indexColumn } );
value.setExplicitType( "integer" );
value.setMappings( mappings );
SimpleValue indexValue = value.make();
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/MapBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/MapBinder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/MapBinder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -13,6 +13,8 @@
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
import org.hibernate.annotations.MapKeyManyToMany;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.AnnotatedClassType;
import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.BinderHelper;
@@ -39,9 +41,6 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XProperty;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.sql.Template;
import org.hibernate.util.StringHelper;
@@ -52,7 +51,7 @@
*/
public class MapBinder extends CollectionBinder {
public MapBinder(boolean sorted) {
- super(sorted);
+ super( sorted );
}
public MapBinder() {
@@ -90,7 +89,7 @@
}
private void bindKeyFromAssociationTable(
- XClass collType, Map persistentClasses, String mapKeyPropertyName, XProperty property,
+ XClass collType, Map persistentClasses, String mapKeyPropertyName, XProperty property,
boolean isEmbedded, ExtendedMappings mappings, Ejb3Column[] mapKeyColumns,
Ejb3JoinColumn[] mapKeyManyToManyColumns, String targetPropertyName
) {
@@ -122,7 +121,7 @@
else if ( property.isAnnotationPresent( MapKeyManyToMany.class ) ) {
target = property.getAnnotation( MapKeyManyToMany.class ).targetEntity();
}
- if ( ! void.class.equals( target ) ) {
+ if ( !void.class.equals( target ) ) {
mapKeyType = target.getName();
}
else {
@@ -229,7 +228,7 @@
elementColumns[0] = column;
}
//override the table
- for ( Ejb3Column column : elementColumns ) {
+ for (Ejb3Column column : elementColumns) {
column.setTable( mapValue.getCollectionTable() );
}
elementBinder.setColumns( elementColumns );
@@ -238,9 +237,9 @@
}
}
//FIXME pass the Index Entity JoinColumns
- if ( ! collection.isOneToMany() ) {
+ if ( !collection.isOneToMany() ) {
//index column shoud not be null
- for ( Ejb3JoinColumn col : mapKeyManyToManyColumns ) {
+ for (Ejb3JoinColumn col : mapKeyManyToManyColumns) {
col.forceNotNull();
}
}
@@ -261,8 +260,8 @@
) {
Value element = collection.getElement();
String fromAndWhere = null;
- if ( ! ( element instanceof OneToMany ) ) {
- String referencedPropertyName= null;
+ if ( !( element instanceof OneToMany ) ) {
+ String referencedPropertyName = null;
if ( element instanceof ToOne ) {
referencedPropertyName = ( (ToOne) element ).getReferencedPropertyName();
}
@@ -276,7 +275,7 @@
}
}
Iterator referencedEntityColumns;
- if (referencedPropertyName == null) {
+ if ( referencedPropertyName == null ) {
referencedEntityColumns = associatedClass.getIdentifier().getColumnIterator();
}
else {
@@ -286,17 +285,17 @@
String alias = "$alias$";
StringBuilder fromAndWhereSb = new StringBuilder( " from " )
.append( associatedClass.getTable().getName() )
- //.append(" as ") //Oracle doesn't support it in subqueries
- .append(" ")
- .append(alias).append(" where ");
+ //.append(" as ") //Oracle doesn't support it in subqueries
+ .append( " " )
+ .append( alias ).append( " where " );
Iterator collectionTableColumns = element.getColumnIterator();
while ( collectionTableColumns.hasNext() ) {
Column colColumn = (Column) collectionTableColumns.next();
Column refColumn = (Column) referencedEntityColumns.next();
- fromAndWhereSb.append(alias).append('.').append( refColumn.getQuotedName() )
- .append('=').append( colColumn.getQuotedName() ).append(" and ");
+ fromAndWhereSb.append( alias ).append( '.' ).append( refColumn.getQuotedName() )
+ .append( '=' ).append( colColumn.getQuotedName() ).append( " and " );
}
- fromAndWhere = fromAndWhereSb.substring(0, fromAndWhereSb.length() - 5 );
+ fromAndWhere = fromAndWhereSb.substring( 0, fromAndWhereSb.length() - 5 );
}
if ( value instanceof Component ) {
@@ -332,7 +331,7 @@
else if ( value instanceof SimpleValue ) {
SimpleValue sourceValue = (SimpleValue) value;
SimpleValue targetValue;
- if( value instanceof ManyToOne ) {
+ if ( value instanceof ManyToOne ) {
ManyToOne sourceManyToOne = (ManyToOne) sourceValue;
ManyToOne targetManyToOne = new ManyToOne( collection.getCollectionTable() );
targetManyToOne.setFetchMode( FetchMode.DEFAULT );
@@ -356,14 +355,14 @@
formulaString = ( (Column) current ).getQuotedName();
}
else if ( current instanceof Formula ) {
- formulaString = ( (Formula) current ).getFormula();
+ formulaString = ( (Formula) current ).getFormula();
}
else {
throw new AssertionFailure( "Unknown element in column iterator: " + current.getClass() );
}
- if (fromAndWhere != null) {
+ if ( fromAndWhere != null ) {
formulaString = Template.renderWhereStringTemplate( formulaString, "$alias$", new HSQLDialect() );
- formulaString = "(select " + formulaString + fromAndWhere + ")";
+ formulaString = "(select " + formulaString + fromAndWhere + ")";
formulaString = StringHelper.replace(
formulaString,
"$alias$",
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/PropertyBinder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/PropertyBinder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -1,16 +1,18 @@
//$Id$
package org.hibernate.cfg.annotations;
+import javax.persistence.EmbeddedId;
import javax.persistence.Id;
-import javax.persistence.EmbeddedId;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;
+import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.OptimisticLock;
-import org.hibernate.annotations.NaturalId;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.PropertyHolder;
@@ -18,8 +20,6 @@
import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.util.StringHelper;
/**
@@ -168,14 +168,14 @@
OptimisticLock lockAnn = property != null ?
property.getAnnotation( OptimisticLock.class ) :
null;
- if ( lockAnn != null) {
- prop.setOptimisticLocked( ! lockAnn.excluded() );
+ if ( lockAnn != null ) {
+ prop.setOptimisticLocked( !lockAnn.excluded() );
//TODO this should go to the core as a mapping validation checking
if ( lockAnn.excluded() && (
property.isAnnotationPresent( javax.persistence.Version.class )
- || property.isAnnotationPresent( Id.class )
- || property.isAnnotationPresent( EmbeddedId.class ) ) ) {
- throw new AnnotationException("@OptimisticLock.exclude=true incompatible with @Id, @EmbeddedId and @Version: "
+ || property.isAnnotationPresent( Id.class )
+ || property.isAnnotationPresent( EmbeddedId.class ) ) ) {
+ throw new AnnotationException( "@OptimisticLock.exclude=true incompatible with @Id, @EmbeddedId and @Version: "
+ StringHelper.qualify( holder.getPath(), name ) );
}
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/QueryBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/QueryBinder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/QueryBinder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -55,7 +55,7 @@
getString( queryName, "org.hibernate.comment", hints ),
null
);
- if (isDefault) {
+ if ( isDefault ) {
mappings.addDefaultQuery( queryAnn.name(), query );
}
else {
@@ -75,7 +75,7 @@
String resultSetMapping = queryAnn.resultSetMapping();
QueryHint[] hints = queryAnn.hints();
String queryName = queryAnn.query();
- if ( ! BinderHelper.isDefault( resultSetMapping ) ) {
+ if ( !BinderHelper.isDefault( resultSetMapping ) ) {
//sql result set usage
query = new NamedSQLQueryDefinition(
queryName,
@@ -93,14 +93,14 @@
getBoolean( queryName, "org.hibernate.callable", hints )
);
}
- else if ( ! void.class.equals( queryAnn.resultClass() ) ) {
+ else if ( !void.class.equals( queryAnn.resultClass() ) ) {
//class mapping usage
//FIXME should be done in a second pass due to entity name?
final NativeSQLQueryRootReturn entityQueryReturn =
new NativeSQLQueryRootReturn( "alias1", queryAnn.resultClass().getName(), new HashMap(), LockMode.READ );
query = new NamedSQLQueryDefinition(
queryName,
- new NativeSQLQueryReturn[]{entityQueryReturn},
+ new NativeSQLQueryReturn[] { entityQueryReturn },
null,
getBoolean( queryName, "org.hibernate.cacheable", hints ),
getString( queryName, "org.hibernate.cacheRegion", hints ),
@@ -117,7 +117,7 @@
else {
throw new NotYetImplementedException( "Pure native scalar queries are not yet supported" );
}
- if (isDefault) {
+ if ( isDefault ) {
mappings.addDefaultSQLQuery( queryAnn.name(), query );
}
else {
@@ -136,7 +136,7 @@
}
NamedSQLQueryDefinition query;
String resultSetMapping = queryAnn.resultSetMapping();
- if ( ! BinderHelper.isDefault( resultSetMapping ) ) {
+ if ( !BinderHelper.isDefault( resultSetMapping ) ) {
//sql result set usage
query = new NamedSQLQueryDefinition(
queryAnn.query(),
@@ -154,14 +154,14 @@
queryAnn.callable()
);
}
- else if ( ! void.class.equals( queryAnn.resultClass() ) ) {
+ else if ( !void.class.equals( queryAnn.resultClass() ) ) {
//class mapping usage
//FIXME should be done in a second pass due to entity name?
final NativeSQLQueryRootReturn entityQueryReturn =
new NativeSQLQueryRootReturn( "alias1", queryAnn.resultClass().getName(), new HashMap(), LockMode.READ );
query = new NamedSQLQueryDefinition(
queryAnn.query(),
- new NativeSQLQueryReturn[]{entityQueryReturn},
+ new NativeSQLQueryReturn[] { entityQueryReturn },
null,
queryAnn.cacheable(),
BinderHelper.isDefault( queryAnn.cacheRegion() ) ? null : queryAnn.cacheRegion(),
@@ -186,14 +186,14 @@
public static void bindQueries(NamedQueries queriesAnn, ExtendedMappings mappings, boolean isDefault) {
if ( queriesAnn == null ) return;
- for ( NamedQuery q : queriesAnn.value() ) {
+ for (NamedQuery q : queriesAnn.value()) {
bindQuery( q, mappings, isDefault );
}
}
public static void bindNativeQueries(NamedNativeQueries queriesAnn, ExtendedMappings mappings, boolean isDefault) {
if ( queriesAnn == null ) return;
- for ( NamedNativeQuery q : queriesAnn.value() ) {
+ for (NamedNativeQuery q : queriesAnn.value()) {
bindNativeQuery( q, mappings, isDefault );
}
}
@@ -202,7 +202,7 @@
org.hibernate.annotations.NamedNativeQueries queriesAnn, ExtendedMappings mappings
) {
if ( queriesAnn == null ) return;
- for ( org.hibernate.annotations.NamedNativeQuery q : queriesAnn.value() ) {
+ for (org.hibernate.annotations.NamedNativeQuery q : queriesAnn.value()) {
bindNativeQuery( q, mappings );
}
}
@@ -277,14 +277,14 @@
public static void bindQueries(org.hibernate.annotations.NamedQueries queriesAnn, ExtendedMappings mappings) {
if ( queriesAnn == null ) return;
- for ( org.hibernate.annotations.NamedQuery q : queriesAnn.value() ) {
+ for (org.hibernate.annotations.NamedQuery q : queriesAnn.value()) {
bindQuery( q, mappings );
}
}
public static void bindSqlResultsetMappings(SqlResultSetMappings ann, ExtendedMappings mappings, boolean isDefault) {
if ( ann == null ) return;
- for ( SqlResultSetMapping rs : ann.value() ) {
+ for (SqlResultSetMapping rs : ann.value()) {
//no need to handle inSecondPass
mappings.addSecondPass( new ResultsetMappingSecondPass( rs, mappings, true ) );
}
@@ -296,7 +296,7 @@
}
private static CacheMode getCacheMode(String query, QueryHint[] hints) {
- for ( QueryHint hint : hints ) {
+ for (QueryHint hint : hints) {
if ( "org.hibernate.cacheMode".equals( hint.name() ) ) {
if ( hint.value().equalsIgnoreCase( CacheMode.GET.toString() ) ) {
return CacheMode.GET;
@@ -322,7 +322,7 @@
}
private static FlushMode getFlushMode(String query, QueryHint[] hints) {
- for ( QueryHint hint : hints ) {
+ for (QueryHint hint : hints) {
if ( "org.hibernate.flushMode".equals( hint.name() ) ) {
if ( hint.value().equalsIgnoreCase( FlushMode.ALWAYS.toString() ) ) {
return FlushMode.ALWAYS;
@@ -348,7 +348,7 @@
}
private static boolean getBoolean(String query, String hintName, QueryHint[] hints) {
- for ( QueryHint hint : hints ) {
+ for (QueryHint hint : hints) {
if ( hintName.equals( hint.name() ) ) {
if ( hint.value().equalsIgnoreCase( "true" ) ) {
return true;
@@ -365,7 +365,7 @@
}
private static String getString(String query, String hintName, QueryHint[] hints) {
- for ( QueryHint hint : hints ) {
+ for (QueryHint hint : hints) {
if ( hintName.equals( hint.name() ) ) {
return hint.value();
}
@@ -374,7 +374,7 @@
}
private static Integer getInteger(String query, String hintName, QueryHint[] hints) {
- for ( QueryHint hint : hints ) {
+ for (QueryHint hint : hints) {
if ( hintName.equals( hint.name() ) ) {
try {
return Integer.decode( hint.value() );
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -54,12 +54,12 @@
int entityAliasIndex = 0;
- for ( EntityResult entity : ann.entities() ) {
+ for (EntityResult entity : ann.entities()) {
//TODO parameterize lock mode?
List properties = new ArrayList();
List propertyNames = new ArrayList();
Map propertyresults = new HashMap();
- for ( FieldResult field : entity.fields() ) {
+ for (FieldResult field : entity.fields()) {
//use an ArrayList cause we might have several columns per root property
String name = field.name();
if ( name.indexOf( '.' ) == -1 ) {
@@ -88,7 +88,7 @@
int index = propertyNames.size();
int followersSize = followers.size();
- for ( int loop = 0; loop < followersSize ; loop++ ) {
+ for (int loop = 0; loop < followersSize; loop++) {
String follower = (String) followers.get( loop );
int currentIndex = getIndexOfFirstMatchingProperty( propertyNames, follower );
index = currentIndex != -1 && currentIndex < index ? currentIndex : index;
@@ -132,12 +132,12 @@
Map.Entry entry = (Map.Entry) entries.next();
if ( entry.getValue() instanceof ArrayList ) {
ArrayList list = (ArrayList) entry.getValue();
- entry.setValue( list.toArray( new String[ list.size() ] ) );
+ entry.setValue( list.toArray( new String[list.size()] ) );
}
}
- if ( ! BinderHelper.isDefault( entity.discriminatorColumn() ) ) {
- propertyresults.put( "class", new String[]{entity.discriminatorColumn()} );
+ if ( !BinderHelper.isDefault( entity.discriminatorColumn() ) ) {
+ propertyresults.put( "class", new String[] { entity.discriminatorColumn() } );
}
propertyresults = propertyresults.isEmpty() ? CollectionHelper.EMPTY_MAP : propertyresults;
@@ -148,11 +148,11 @@
definition.addQueryReturn( result );
}
- for ( ColumnResult column : ann.columns() ) {
+ for (ColumnResult column : ann.columns()) {
definition.addQueryReturn( new NativeSQLQueryScalarReturn( column.name(), null ) );
}
- if (isDefault) {
+ if ( isDefault ) {
mappings.addDefaultResultSetMapping( definition );
}
else {
@@ -221,7 +221,7 @@
private static int getIndexOfFirstMatchingProperty(List propertyNames, String follower) {
int propertySize = propertyNames.size();
- for ( int propIndex = 0; propIndex < propertySize ; propIndex++ ) {
+ for (int propIndex = 0; propIndex < propertySize; propIndex++) {
if ( ( (String) propertyNames.get( propIndex ) ).startsWith( follower ) ) {
return propIndex;
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -16,14 +16,14 @@
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.type.ByteArrayBlobType;
import org.hibernate.type.CharacterArrayClobType;
import org.hibernate.type.EnumType;
@@ -102,7 +102,7 @@
break;
case TIME:
type = "time";
- if ( ! isDate ) {
+ if ( !isDate ) {
throw new NotYetImplementedException(
"Calendar cannot persist TIME only"
+ StringHelper.qualify( persistentClassName, propertyName )
@@ -200,7 +200,7 @@
if ( typeAnn != null ) {
explicitType = typeAnn.type();
typeParameters.clear();
- for ( Parameter param : typeAnn.parameters() ) {
+ for (Parameter param : typeAnn.parameters()) {
typeParameters.setProperty( param.name(), param.value() );
}
}
@@ -218,7 +218,7 @@
public SimpleValue make() {
validate();
log.debug( "building SimpleValue for " + propertyName );
- if (table == null) {
+ if ( table == null ) {
table = columns[0].getTable();
}
SimpleValue simpleValue = new SimpleValue( table );
@@ -240,7 +240,7 @@
if ( persistentClassName != null ) {
simpleValue.setTypeUsingReflection( persistentClassName, propertyName );
}
- for ( Ejb3Column column : columns ) {
+ for (Ejb3Column column : columns) {
column.linkWithValue( simpleValue );
}
return simpleValue;
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -106,13 +106,13 @@
}
else {
extendedName = mappings.getNamingStrategy()
- .collectionTableName(
- ownerEntity,
- unquotedOwnerTable,
- associatedEntity,
- unquotedAssocTable,
- propertyName
- );
+ .collectionTableName(
+ ownerEntity,
+ unquotedOwnerTable,
+ associatedEntity,
+ unquotedAssocTable,
+ propertyName
+ );
if ( StringHelper.isQuoted( ownerEntityTable ) || StringHelper.isQuoted( associatedEntityTable ) ) {
extendedName = StringHelper.quote( extendedName );
}
@@ -292,12 +292,12 @@
Iterator idColItr = referencedEntity.getKey().getColumnIterator();
org.hibernate.mapping.Column col;
Table table = referencedEntity.getTable(); //works cause the pk has to be on the primary table
- if ( ! idColItr.hasNext() ) log.debug( "No column in the identifier!" );
+ if ( !idColItr.hasNext() ) log.debug( "No column in the identifier!" );
while ( idColItr.hasNext() ) {
boolean match = false;
//for each PK column, find the associated FK column.
col = (org.hibernate.mapping.Column) idColItr.next();
- for ( Ejb3JoinColumn joinCol : columns ) {
+ for (Ejb3JoinColumn joinCol : columns) {
String referencedColumn = joinCol.getReferencedColumn();
referencedColumn = mappings.getPhysicalColumnName( referencedColumn, table );
if ( referencedColumn.equals( col.getName() ) ) {
@@ -334,7 +334,7 @@
private static void linkJoinColumnWithValueOverridingNameIfImplicit(
PersistentClass referencedEntity, Iterator columnIterator, Ejb3JoinColumn[] columns, SimpleValue value
) {
- for ( Ejb3JoinColumn joinCol : columns ) {
+ for (Ejb3JoinColumn joinCol : columns) {
Column synthCol = (Column) columnIterator.next();
if ( joinCol.isNameDeferred() ) {
//this has to be the default value
@@ -357,7 +357,7 @@
}
public static void addIndexes(Table hibTable, Index[] indexes, ExtendedMappings mappings) {
- for ( Index index : indexes ) {
+ for (Index index : indexes) {
//no need to handle inSecondPass here since it is only called from EntityBinder
mappings.addSecondPass(
new IndexOrUniqueKeySecondPass( hibTable, index.name(), index.columnNames(), mappings )
@@ -368,7 +368,7 @@
public static List<String[]> buildUniqueConstraints(UniqueConstraint[] constraintsArray) {
List<String[]> result = new ArrayList<String[]>();
if ( constraintsArray.length != 0 ) {
- for ( UniqueConstraint uc : constraintsArray ) {
+ for (UniqueConstraint uc : constraintsArray) {
result.add( uc.columnNames() );
}
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -8,12 +8,11 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.HashSet;
-
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
@@ -81,22 +80,21 @@
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.dom4j.Attribute;
import org.dom4j.Element;
import org.hibernate.AnnotationException;
-import org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor;
-import org.hibernate.annotations.common.annotationfactory.AnnotationFactory;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.Columns;
+import org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor;
+import org.hibernate.annotations.common.annotationfactory.AnnotationFactory;
import org.hibernate.annotations.common.reflection.AnnotationReader;
import org.hibernate.annotations.common.reflection.Filter;
import org.hibernate.annotations.common.reflection.ReflectionUtil;
-import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* Encapsulates the overriding of Java annotations from an EJB 3.0 descriptor.
@@ -184,11 +182,11 @@
private String propertyName;
private PropertyType propertyType;
private transient Annotation[] annotations;
- private transient Map<Class, Annotation> annotationsMap;
- private static final String WORD_SEPARATOR = "-";
+ private transient Map<Class, Annotation> annotationsMap;
+ private static final String WORD_SEPARATOR = "-";
private transient List<Element> elementsForProperty;
private AccessibleObject mirroredAttribute;
- private final AnnotatedElement element;
+ private final AnnotatedElement element;
private enum PropertyType {
PROPERTY,
@@ -197,7 +195,7 @@
}
public EJB3OverridenAnnotationReader(AnnotatedElement el, XMLContext xmlContext) {
- this.element = el;
+ this.element = el;
this.xmlContext = xmlContext;
if ( el instanceof Class ) {
Class clazz = (Class) el;
@@ -256,7 +254,7 @@
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
initAnnotations();
- return (T) annotationsMap.get( annotationType );
+ return (T) annotationsMap.get( annotationType );
}
public <T extends Annotation> boolean isAnnotationPresent(Class<T> annotationType) {
@@ -271,15 +269,15 @@
private void initAnnotations() {
if ( annotations == null ) {
- XMLContext.Default defaults = xmlContext.getDefault( className );
+ XMLContext.Default defaults = xmlContext.getDefault( className );
if ( className != null && propertyName == null ) {
//is a class
Element tree = xmlContext.getXMLTree( className, null );
- Annotation[] annotations = getJavaAnnotations();
+ Annotation[] annotations = getJavaAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 );
- annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
- for ( Annotation annotation : annotations ) {
- if ( ! annotationToXml.containsKey( annotation.annotationType() ) ) {
+ annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
+ for (Annotation annotation : annotations) {
+ if ( !annotationToXml.containsKey( annotation.annotationType() ) ) {
//unknown annotations are left over
annotationList.add( annotation );
}
@@ -305,20 +303,20 @@
addIfNotNull( annotationList, getAttributeOverrides( tree, defaults ) );
addIfNotNull( annotationList, getAssociationOverrides( tree, defaults ) );
addIfNotNull( annotationList, getEntityListeners( tree, defaults ) );
- //FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
- this.annotations = annotationList.toArray( new Annotation[ annotationList.size() ] );
- for (Annotation ann : this.annotations) {
- annotationsMap.put( ann.annotationType(), ann );
- }
- checkForOrphanProperties(tree);
+ //FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
+ this.annotations = annotationList.toArray( new Annotation[annotationList.size()] );
+ for (Annotation ann : this.annotations) {
+ annotationsMap.put( ann.annotationType(), ann );
+ }
+ checkForOrphanProperties( tree );
}
else if ( className != null ) { //&& propertyName != null ) { //always true but less confusing
Element tree = xmlContext.getXMLTree( className, propertyName );
Annotation[] annotations = getJavaAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 );
- annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
- for ( Annotation annotation : annotations ) {
- if ( ! annotationToXml.containsKey( annotation.annotationType() ) ) {
+ annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
+ for (Annotation annotation : annotations) {
+ if ( !annotationToXml.containsKey( annotation.annotationType() ) ) {
//unknown annotations are left over
annotationList.add( annotation );
}
@@ -331,7 +329,7 @@
else {
if ( defaults.canUseJavaAnnotations() ) {
Annotation annotation = getJavaAnnotation( AccessType.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
}
getId( annotationList, defaults );
getEmbeddedId( annotationList, defaults );
@@ -342,25 +340,25 @@
getAssociation( OneToOne.class, annotationList, defaults );
getAssociation( OneToMany.class, annotationList, defaults );
getAssociation( ManyToMany.class, annotationList, defaults );
- addIfNotNull(annotationList, getSequenceGenerator( elementsForProperty, defaults ));
- addIfNotNull(annotationList, getTableGenerator( elementsForProperty, defaults ));
- addIfNotNull(annotationList, getAttributeOverrides( elementsForProperty, defaults ));
+ addIfNotNull( annotationList, getSequenceGenerator( elementsForProperty, defaults ) );
+ addIfNotNull( annotationList, getTableGenerator( elementsForProperty, defaults ) );
+ addIfNotNull( annotationList, getAttributeOverrides( elementsForProperty, defaults ) );
}
- processEventAnnotations(annotationList, defaults);
+ processEventAnnotations( annotationList, defaults );
//FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
- this.annotations = annotationList.toArray( new Annotation[ annotationList.size() ] );
- for (Annotation ann : this.annotations) {
- annotationsMap.put( ann.annotationType(), ann );
- }
- }
+ this.annotations = annotationList.toArray( new Annotation[annotationList.size()] );
+ for (Annotation ann : this.annotations) {
+ annotationsMap.put( ann.annotationType(), ann );
+ }
+ }
else {
this.annotations = getJavaAnnotations();
annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
for (Annotation ann : this.annotations) {
- annotationsMap.put( ann.annotationType(), ann );
- }
- }
+ annotationsMap.put( ann.annotationType(), ann );
+ }
+ }
}
}
@@ -378,10 +376,10 @@
//precompute the list of properties
//TODO is it really useful...
Set<String> properties = new HashSet<String>();
- for (Field field : clazz.getFields() ) {
+ for (Field field : clazz.getFields()) {
properties.add( field.getName() );
}
- for (Method method : clazz.getMethods() ) {
+ for (Method method : clazz.getMethods()) {
String name = method.getName();
if ( name.startsWith( "get" ) ) {
properties.add( Introspector.decapitalize( name.substring( "get".length() ) ) );
@@ -390,61 +388,61 @@
properties.add( Introspector.decapitalize( name.substring( "is".length() ) ) );
}
}
- for ( Element subelement : (List<Element>) element.elements() ) {
+ for (Element subelement : (List<Element>) element.elements()) {
String propertyName = subelement.attributeValue( "name" );
- if ( ! properties.contains( propertyName ) ) {
- log.warn("Property " + StringHelper.qualify( className, propertyName ) + " not found in class"
- + " but described in <mapping-file/> (possible typo error)");
+ if ( !properties.contains( propertyName ) ) {
+ log.warn( "Property " + StringHelper.qualify( className, propertyName ) + " not found in class"
+ + " but described in <mapping-file/> (possible typo error)" );
}
}
}
}
/**
- * Addes the Annotation to the list (only if it's not null) and then returns it.
- */
- private Annotation addIfNotNull(List<Annotation> annotationList, Annotation element) {
- if ( element != null ) {
- annotationList.add( element );
- }
- return element;
- }
+ * Addes the Annotation to the list (only if it's not null) and then returns it.
+ */
+ private Annotation addIfNotNull(List<Annotation> annotationList, Annotation element) {
+ if ( element != null ) {
+ annotationList.add( element );
+ }
+ return element;
+ }
- //TODO mutualize the next 2 methods
- private Annotation getTableGenerator(List<Element> elementsForProperty, XMLContext.Default defaults) {
- for (Element element : elementsForProperty) {
- Element subelement = element != null ? element.element( annotationToXml.get( TableGenerator.class ) ) : null;
- if ( subelement != null ) {
- return buildTableGeneratorAnnotation( subelement, defaults );
- }
- }
- if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
- return getJavaAnnotation( TableGenerator.class );
+ //TODO mutualize the next 2 methods
+ private Annotation getTableGenerator(List<Element> elementsForProperty, XMLContext.Default defaults) {
+ for (Element element : elementsForProperty) {
+ Element subelement = element != null ? element.element( annotationToXml.get( TableGenerator.class ) ) : null;
+ if ( subelement != null ) {
+ return buildTableGeneratorAnnotation( subelement, defaults );
+ }
}
+ if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
+ return getJavaAnnotation( TableGenerator.class );
+ }
else {
return null;
}
- }
+ }
- private Annotation getSequenceGenerator(List<Element> elementsForProperty, XMLContext.Default defaults) {
- for (Element element : elementsForProperty) {
- Element subelement = element != null ? element.element( annotationToXml.get( SequenceGenerator.class ) ) : null;
- if ( subelement != null ) {
- return buildSequenceGeneratorAnnotation( subelement );
- }
- }
- if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
- return getJavaAnnotation( SequenceGenerator.class );
+ private Annotation getSequenceGenerator(List<Element> elementsForProperty, XMLContext.Default defaults) {
+ for (Element element : elementsForProperty) {
+ Element subelement = element != null ? element.element( annotationToXml.get( SequenceGenerator.class ) ) : null;
+ if ( subelement != null ) {
+ return buildSequenceGeneratorAnnotation( subelement );
+ }
}
+ if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
+ return getJavaAnnotation( SequenceGenerator.class );
+ }
else {
return null;
}
- }
+ }
- private void processEventAnnotations(List<Annotation> annotationList, XMLContext.Default defaults) {
+ private void processEventAnnotations(List<Annotation> annotationList, XMLContext.Default defaults) {
boolean eventElement = false;
- for ( Element element : elementsForProperty ) {
+ for (Element element : elementsForProperty) {
String elementName = element.getName();
if ( "pre-persist".equals( elementName ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( PrePersist.class );
@@ -482,29 +480,29 @@
eventElement = true;
}
}
- if ( ! eventElement && defaults.canUseJavaAnnotations() ) {
- Annotation ann = getJavaAnnotation(PrePersist.class);
- addIfNotNull(annotationList, ann);
- ann = getJavaAnnotation(PreRemove.class);
- addIfNotNull(annotationList, ann);
- ann = getJavaAnnotation(PreUpdate.class);
- addIfNotNull(annotationList, ann);
- ann = getJavaAnnotation(PostPersist.class);
- addIfNotNull(annotationList, ann);
- ann = getJavaAnnotation(PostRemove.class);
- addIfNotNull(annotationList, ann);
- ann = getJavaAnnotation(PostUpdate.class);
- addIfNotNull(annotationList, ann);
- ann = getJavaAnnotation(PostLoad.class);
- addIfNotNull(annotationList, ann);
+ if ( !eventElement && defaults.canUseJavaAnnotations() ) {
+ Annotation ann = getJavaAnnotation( PrePersist.class );
+ addIfNotNull( annotationList, ann );
+ ann = getJavaAnnotation( PreRemove.class );
+ addIfNotNull( annotationList, ann );
+ ann = getJavaAnnotation( PreUpdate.class );
+ addIfNotNull( annotationList, ann );
+ ann = getJavaAnnotation( PostPersist.class );
+ addIfNotNull( annotationList, ann );
+ ann = getJavaAnnotation( PostRemove.class );
+ addIfNotNull( annotationList, ann );
+ ann = getJavaAnnotation( PostUpdate.class );
+ addIfNotNull( annotationList, ann );
+ ann = getJavaAnnotation( PostLoad.class );
+ addIfNotNull( annotationList, ann );
}
}
private EntityListeners getEntityListeners(Element tree, XMLContext.Default defaults) {
Element element = tree != null ? tree.element( "entity-listeners" ) : null;
- if ( element != null) {
+ if ( element != null ) {
List<Class> entityListenerClasses = new ArrayList<Class>();
- for (Element subelement : (List<Element>) element.elements( "entity-listener" ) ) {
+ for (Element subelement : (List<Element>) element.elements( "entity-listener" )) {
String className = subelement.attributeValue( "class" );
try {
entityListenerClasses.add(
@@ -521,7 +519,7 @@
}
}
AnnotationDescriptor ad = new AnnotationDescriptor( EntityListeners.class );
- ad.setValue( "value", entityListenerClasses.toArray( new Class[ entityListenerClasses.size() ] ) );
+ ad.setValue( "value", entityListenerClasses.toArray( new Class[entityListenerClasses.size()] ) );
return AnnotationFactory.create( ad );
}
else if ( defaults.canUseJavaAnnotations() ) {
@@ -534,18 +532,18 @@
private JoinTable overridesDefaultsInJoinTable(Annotation annotation, XMLContext.Default defaults) {
//no element but might have some default or some annotation
- boolean defaultToJoinTable = ! ( isJavaAnnotationPresent( JoinColumn.class )
+ boolean defaultToJoinTable = !( isJavaAnnotationPresent( JoinColumn.class )
|| isJavaAnnotationPresent( JoinColumns.class ) );
- final Class<? extends Annotation> annotationClass = annotation.annotationType();
- defaultToJoinTable = defaultToJoinTable &&
- ( ( annotationClass == ManyToMany.class && StringHelper.isEmpty( ( (ManyToMany) annotation).mappedBy() ) )
- || ( annotationClass == OneToMany.class && StringHelper.isEmpty( ( (OneToMany) annotation).mappedBy() ) )
- || ( annotationClass == CollectionOfElements.class )
+ final Class<? extends Annotation> annotationClass = annotation.annotationType();
+ defaultToJoinTable = defaultToJoinTable &&
+ ( ( annotationClass == ManyToMany.class && StringHelper.isEmpty( ( (ManyToMany) annotation ).mappedBy() ) )
+ || ( annotationClass == OneToMany.class && StringHelper.isEmpty( ( (OneToMany) annotation ).mappedBy() ) )
+ || ( annotationClass == CollectionOfElements.class )
);
final Class<JoinTable> annotationType = JoinTable.class;
if ( defaultToJoinTable
&& ( StringHelper.isNotEmpty( defaults.getCatalog() )
- || StringHelper.isNotEmpty( defaults.getSchema() ) ) ) {
+ || StringHelper.isNotEmpty( defaults.getSchema() ) ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( annotationType );
if ( defaults.canUseJavaAnnotations() ) {
JoinTable table = getJavaAnnotation( annotationType );
@@ -607,7 +605,7 @@
Class<? extends Annotation> annotationType, List<Annotation> annotationList, XMLContext.Default defaults
) {
String xmlName = annotationToXml.get( annotationType );
- for ( Element element : elementsForProperty ) {
+ for (Element element : elementsForProperty) {
if ( xmlName.equals( element.getName() ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( annotationType );
String className = element.attributeValue( "target-entity" );
@@ -631,7 +629,7 @@
getJoinTable( annotationList, element, defaults );
buildJoinColumns( annotationList, element, defaults );
Annotation annotation = getPrimaryKeyJoinColumns( element, defaults );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
copyBooleanAttribute( ad, element, "optional" );
copyStringAttribute( ad, element, "mapped-by", false );
getOrderBy( annotationList, element, defaults );
@@ -644,71 +642,71 @@
if ( annotation != null ) {
annotationList.add( annotation );
annotation = overridesDefaultsInJoinTable( annotation, defaults );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( JoinColumn.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( JoinColumns.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( PrimaryKeyJoinColumn.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( PrimaryKeyJoinColumns.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( MapKey.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( OrderBy.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Lob.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Enumerated.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Temporal.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Column.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Columns.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
}
else if ( isJavaAnnotationPresent( CollectionOfElements.class ) ) {
annotation = overridesDefaultsInJoinTable( getJavaAnnotation( CollectionOfElements.class ), defaults );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( JoinColumn.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( JoinColumns.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( PrimaryKeyJoinColumn.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( PrimaryKeyJoinColumns.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( MapKey.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( OrderBy.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Lob.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Enumerated.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Temporal.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Column.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Columns.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
}
}
}
@@ -745,7 +743,7 @@
private void getCascades(AnnotationDescriptor ad, Element element, XMLContext.Default defaults) {
List<Element> elements = element != null ? element.elements( "cascade" ) : new ArrayList<Element>( 0 );
List<CascadeType> cascades = new ArrayList<CascadeType>();
- for ( Element subelement : elements ) {
+ for (Element subelement : elements) {
if ( subelement.element( "cascade-all" ) != null ) cascades.add( CascadeType.ALL );
if ( subelement.element( "cascade-persist" ) != null ) cascades.add( CascadeType.PERSIST );
if ( subelement.element( "cascade-merge" ) != null ) cascades.add( CascadeType.MERGE );
@@ -753,16 +751,16 @@
if ( subelement.element( "cascade-refresh" ) != null ) cascades.add( CascadeType.REFRESH );
}
if ( Boolean.TRUE.equals( defaults.getCascadePersist() )
- && ! cascades.contains( CascadeType.ALL ) && ! cascades.contains( CascadeType.PERSIST ) ) {
+ && !cascades.contains( CascadeType.ALL ) && !cascades.contains( CascadeType.PERSIST ) ) {
cascades.add( CascadeType.PERSIST );
}
if ( cascades.size() > 0 ) {
- ad.setValue( "cascade", cascades.toArray( new CascadeType[ cascades.size() ] ) );
+ ad.setValue( "cascade", cascades.toArray( new CascadeType[cascades.size()] ) );
}
}
private void getEmbedded(List<Annotation> annotationList, XMLContext.Default defaults) {
- for ( Element element : elementsForProperty ) {
+ for (Element element : elementsForProperty) {
if ( "embedded".equals( element.getName() ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( Embedded.class );
annotationList.add( AnnotationFactory.create( ad ) );
@@ -773,19 +771,19 @@
if ( annotation != null ) {
annotationList.add( annotation );
annotation = getJavaAnnotation( AttributeOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
}
}
}
private Transient getTransient(XMLContext.Default defaults) {
- for ( Element element : elementsForProperty ) {
+ for (Element element : elementsForProperty) {
if ( "transient".equals( element.getName() ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( Transient.class );
return AnnotationFactory.create( ad );
@@ -800,10 +798,10 @@
}
private void getVersion(List<Annotation> annotationList, XMLContext.Default defaults) {
- for ( Element element : elementsForProperty ) {
+ for (Element element : elementsForProperty) {
if ( "version".equals( element.getName() ) ) {
Annotation annotation = buildColumns( element );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
getTemporal( annotationList, element );
AnnotationDescriptor basic = new AnnotationDescriptor( Version.class );
annotationList.add( AnnotationFactory.create( basic ) );
@@ -815,20 +813,20 @@
if ( annotation != null ) {
annotationList.add( annotation );
annotation = getJavaAnnotation( Column.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Columns.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Temporal.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
}
}
}
private void getBasic(List<Annotation> annotationList, XMLContext.Default defaults) {
- for ( Element element : elementsForProperty ) {
+ for (Element element : elementsForProperty) {
if ( "basic".equals( element.getName() ) ) {
Annotation annotation = buildColumns( element );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
getTemporal( annotationList, element );
getLob( annotationList, element );
getEnumerated( annotationList, element );
@@ -841,25 +839,25 @@
if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
//no annotation presence constraint, basic is the default
Annotation annotation = getJavaAnnotation( Basic.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Lob.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Enumerated.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Temporal.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Column.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Columns.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
}
}
@@ -901,13 +899,13 @@
}
private void getEmbeddedId(List<Annotation> annotationList, XMLContext.Default defaults) {
- for ( Element element : elementsForProperty ) {
+ for (Element element : elementsForProperty) {
if ( "embedded-id".equals( element.getName() ) ) {
if ( isProcessingId( defaults ) ) {
Annotation annotation = getAttributeOverrides( element, defaults );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getAssociationOverrides( element, defaults );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
AnnotationDescriptor ad = new AnnotationDescriptor( EmbeddedId.class );
annotationList.add( AnnotationFactory.create( ad ) );
}
@@ -933,25 +931,25 @@
if ( annotation != null ) {
annotationList.add( annotation );
annotation = getJavaAnnotation( Column.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Columns.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( GeneratedValue.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Temporal.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( TableGenerator.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( SequenceGenerator.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
}
}
}
@@ -961,15 +959,15 @@
Element element = tree != null ? tree.element( "attributes" ) : null;
//put entity.attributes elements
if ( element != null ) {
- for ( Element subelement : (List<Element>) element.elements() ) {
+ for (Element subelement : (List<Element>) element.elements()) {
if ( propertyName.equals( subelement.attributeValue( "name" ) ) ) {
elementsForProperty.add( subelement );
}
}
}
//add pre-* etc from entity and pure entity listener classes
- if (tree != null) {
- for ( Element subelement : (List<Element>) tree.elements() ) {
+ if ( tree != null ) {
+ for (Element subelement : (List<Element>) tree.elements()) {
if ( propertyName.equals( subelement.attributeValue( "method-name" ) ) ) {
elementsForProperty.add( subelement );
}
@@ -978,20 +976,20 @@
}
private void getId(List<Annotation> annotationList, XMLContext.Default defaults) {
- for ( Element element : elementsForProperty ) {
+ for (Element element : elementsForProperty) {
if ( "id".equals( element.getName() ) ) {
boolean processId = isProcessingId( defaults );
if ( processId ) {
Annotation annotation = buildColumns( element );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = buildGeneratedValue( element );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
getTemporal( annotationList, element );
//FIXME: fix the priority of xml over java for generator names
annotation = getTableGenerator( element, defaults );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getSequenceGenerator( element, defaults );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
AnnotationDescriptor id = new AnnotationDescriptor( Id.class );
annotationList.add( AnnotationFactory.create( id ) );
}
@@ -1015,25 +1013,25 @@
if ( annotation != null ) {
annotationList.add( annotation );
annotation = getJavaAnnotation( Column.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Columns.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( GeneratedValue.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Temporal.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( TableGenerator.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( SequenceGenerator.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverride.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverrides.class );
- addIfNotNull(annotationList, annotation);
+ addIfNotNull( annotationList, annotation );
}
}
}
@@ -1042,28 +1040,28 @@
boolean isExplicit = defaults.getAccess() != null;
boolean correctAccess =
( PropertyType.PROPERTY.equals( propertyType ) && "property".equals( defaults.getAccess() ) )
- || ( PropertyType.FIELD.equals( propertyType ) && "field".equals( defaults.getAccess() ) );
+ || ( PropertyType.FIELD.equals( propertyType ) && "field".equals( defaults.getAccess() ) );
boolean hasId = defaults.canUseJavaAnnotations()
&& ( isJavaAnnotationPresent( Id.class ) || isJavaAnnotationPresent( EmbeddedId.class ) );
//if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) {
boolean mirrorAttributeIsId = defaults.canUseJavaAnnotations() &&
( mirroredAttribute != null &&
- ( mirroredAttribute.isAnnotationPresent(Id.class)
- || mirroredAttribute.isAnnotationPresent( EmbeddedId.class ) ) );
+ ( mirroredAttribute.isAnnotationPresent( Id.class )
+ || mirroredAttribute.isAnnotationPresent( EmbeddedId.class ) ) );
boolean propertyIsDefault = PropertyType.PROPERTY.equals( propertyType )
- && ! mirrorAttributeIsId;
- return correctAccess || ( ! isExplicit && hasId ) || ( ! isExplicit && propertyIsDefault );
+ && !mirrorAttributeIsId;
+ return correctAccess || ( !isExplicit && hasId ) || ( !isExplicit && propertyIsDefault );
}
private Columns buildColumns(Element element) {
List<Element> subelements = element.elements( "column" );
List<Column> columns = new ArrayList<Column>( subelements.size() );
- for ( Element subelement : subelements ) {
+ for (Element subelement : subelements) {
columns.add( getColumn( subelement, false, element ) );
}
if ( columns.size() > 0 ) {
AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class );
- columnsDescr.setValue( "columns", columns.toArray( new Column[ columns.size() ] ) );
+ columnsDescr.setValue( "columns", columns.toArray( new Column[columns.size()] ) );
return AnnotationFactory.create( columnsDescr );
}
else {
@@ -1127,14 +1125,14 @@
addAssociationOverrideIfNeeded( annotation, attributes );
AssociationOverrides annotations = getJavaAnnotation( AssociationOverrides.class );
if ( annotations != null ) {
- for ( AssociationOverride current : annotations.value() ) {
+ for (AssociationOverride current : annotations.value()) {
addAssociationOverrideIfNeeded( current, attributes );
}
}
}
if ( attributes.size() > 0 ) {
AnnotationDescriptor ad = new AnnotationDescriptor( AssociationOverrides.class );
- ad.setValue( "value", attributes.toArray( new AssociationOverride[ attributes.size() ] ) );
+ ad.setValue( "value", attributes.toArray( new AssociationOverride[attributes.size()] ) );
return AnnotationFactory.create( ad );
}
else {
@@ -1146,7 +1144,7 @@
List<Element> subelements = element == null ? null : element.elements( "association-override" );
List<AssociationOverride> overrides = new ArrayList<AssociationOverride>();
if ( subelements != null && subelements.size() > 0 ) {
- for ( Element current : subelements ) {
+ for (Element current : subelements) {
AnnotationDescriptor override = new AnnotationDescriptor( AssociationOverride.class );
copyStringAttribute( override, current, "name", true );
override.setValue( "joinColumns", getJoinColumns( current, false ) );
@@ -1162,7 +1160,7 @@
null;
List<JoinColumn> joinColumns = new ArrayList<JoinColumn>();
if ( subelements != null ) {
- for ( Element subelement : subelements ) {
+ for (Element subelement : subelements) {
AnnotationDescriptor column = new AnnotationDescriptor( JoinColumn.class );
copyStringAttribute( column, subelement, "name", false );
copyStringAttribute( column, subelement, "referenced-column-name", false );
@@ -1175,14 +1173,14 @@
joinColumns.add( (JoinColumn) AnnotationFactory.create( column ) );
}
}
- return joinColumns.toArray( new JoinColumn[ joinColumns.size() ] );
+ return joinColumns.toArray( new JoinColumn[joinColumns.size()] );
}
private void addAssociationOverrideIfNeeded(AssociationOverride annotation, List<AssociationOverride> overrides) {
if ( annotation != null ) {
String overrideName = annotation.name();
boolean present = false;
- for ( AssociationOverride current : overrides ) {
+ for (AssociationOverride current : overrides) {
if ( current.name().equals( overrideName ) ) {
present = true;
break;
@@ -1212,14 +1210,14 @@
addAttributeOverrideIfNeeded( annotation, attributes );
AttributeOverrides annotations = getJavaAnnotation( AttributeOverrides.class );
if ( annotations != null ) {
- for ( AttributeOverride current : annotations.value() ) {
+ for (AttributeOverride current : annotations.value()) {
addAttributeOverrideIfNeeded( current, attributes );
}
}
}
if ( attributes.size() > 0 ) {
AnnotationDescriptor ad = new AnnotationDescriptor( AttributeOverrides.class );
- ad.setValue( "value", attributes.toArray( new AttributeOverride[ attributes.size() ] ) );
+ ad.setValue( "value", attributes.toArray( new AttributeOverride[attributes.size()] ) );
return AnnotationFactory.create( ad );
}
else {
@@ -1235,8 +1233,8 @@
private List<AttributeOverride> buildAttributeOverrides(List<Element> subelements) {
List<AttributeOverride> overrides = new ArrayList<AttributeOverride>();
if ( subelements != null && subelements.size() > 0 ) {
- for ( Element current : subelements ) {
- if ( ! current.getName().equals( "attribute-override" ) ) continue;
+ for (Element current : subelements) {
+ if ( !current.getName().equals( "attribute-override" ) ) continue;
AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class );
copyStringAttribute( override, current, "name", true );
Element column = current != null ? current.element( "column" ) : null;
@@ -1275,7 +1273,7 @@
if ( annotation != null ) {
String overrideName = annotation.name();
boolean present = false;
- for ( AttributeOverride current : overrides ) {
+ for (AttributeOverride current : overrides) {
if ( current.name().equals( overrideName ) ) {
present = true;
break;
@@ -1340,14 +1338,14 @@
addSqlResultsetMappingIfNeeded( annotation, results );
SqlResultSetMappings annotations = getJavaAnnotation( SqlResultSetMappings.class );
if ( annotations != null ) {
- for ( SqlResultSetMapping current : annotations.value() ) {
+ for (SqlResultSetMapping current : annotations.value()) {
addSqlResultsetMappingIfNeeded( current, results );
}
}
}
if ( results.size() > 0 ) {
AnnotationDescriptor ad = new AnnotationDescriptor( SqlResultSetMappings.class );
- ad.setValue( "value", results.toArray( new SqlResultSetMapping[ results.size() ] ) );
+ ad.setValue( "value", results.toArray( new SqlResultSetMapping[results.size()] ) );
return AnnotationFactory.create( ad );
}
else {
@@ -1366,7 +1364,7 @@
copyStringAttribute( ann, subelement, "name", true );
List<Element> elements = subelement.elements( "entity-result" );
List<EntityResult> entityResults = new ArrayList<EntityResult>( elements.size() );
- for ( Element entityResult : elements ) {
+ for (Element entityResult : elements) {
AnnotationDescriptor entityResultDescriptor = new AnnotationDescriptor( EntityResult.class );
String clazzName = entityResult.attributeValue( "entity-class" );
if ( clazzName == null ) {
@@ -1385,27 +1383,27 @@
entityResultDescriptor.setValue( "entityClass", clazz );
copyStringAttribute( entityResultDescriptor, entityResult, "discriminator-column", false );
List<FieldResult> fieldResults = new ArrayList<FieldResult>();
- for ( Element fieldResult : (List<Element>) entityResult.elements( "field-result" ) ) {
+ for (Element fieldResult : (List<Element>) entityResult.elements( "field-result" )) {
AnnotationDescriptor fieldResultDescriptor = new AnnotationDescriptor( FieldResult.class );
copyStringAttribute( fieldResultDescriptor, fieldResult, "name", true );
copyStringAttribute( fieldResultDescriptor, fieldResult, "column", true );
fieldResults.add( (FieldResult) AnnotationFactory.create( fieldResultDescriptor ) );
}
entityResultDescriptor.setValue(
- "fields", fieldResults.toArray( new FieldResult[ fieldResults.size() ] )
+ "fields", fieldResults.toArray( new FieldResult[fieldResults.size()] )
);
entityResults.add( (EntityResult) AnnotationFactory.create( entityResultDescriptor ) );
}
- ann.setValue( "entities", entityResults.toArray( new EntityResult[ entityResults.size() ] ) );
+ ann.setValue( "entities", entityResults.toArray( new EntityResult[entityResults.size()] ) );
elements = subelement.elements( "column-result" );
List<ColumnResult> columnResults = new ArrayList<ColumnResult>( elements.size() );
- for ( Element columnResult : elements ) {
+ for (Element columnResult : elements) {
AnnotationDescriptor columnResultDescriptor = new AnnotationDescriptor( ColumnResult.class );
copyStringAttribute( columnResultDescriptor, columnResult, "name", true );
columnResults.add( (ColumnResult) AnnotationFactory.create( columnResultDescriptor ) );
}
- ann.setValue( "columns", columnResults.toArray( new ColumnResult[ columnResults.size() ] ) );
+ ann.setValue( "columns", columnResults.toArray( new ColumnResult[columnResults.size()] ) );
//FIXME there is never such a result-class, get rid of it?
String clazzName = subelement.attributeValue( "result-class" );
if ( StringHelper.isNotEmpty( clazzName ) ) {
@@ -1431,7 +1429,7 @@
if ( annotation != null ) {
String resultsetName = annotation.name();
boolean present = false;
- for ( SqlResultSetMapping current : resultsets ) {
+ for (SqlResultSetMapping current : resultsets) {
if ( current.name().equals( resultsetName ) ) {
present = true;
break;
@@ -1442,21 +1440,21 @@
}
private NamedQueries getNamedQueries(Element tree, XMLContext.Default defaults) {
- //TODO avoid the Proxy Creation (@NamedQueries) when possible
- List<NamedQuery> queries = (List<NamedQuery>) buildNamedQueries( tree, false, defaults );
+ //TODO avoid the Proxy Creation (@NamedQueries) when possible
+ List<NamedQuery> queries = (List<NamedQuery>) buildNamedQueries( tree, false, defaults );
if ( defaults.canUseJavaAnnotations() ) {
NamedQuery annotation = getJavaAnnotation( NamedQuery.class );
addNamedQueryIfNeeded( annotation, queries );
NamedQueries annotations = getJavaAnnotation( NamedQueries.class );
if ( annotations != null ) {
- for ( NamedQuery current : annotations.value() ) {
+ for (NamedQuery current : annotations.value()) {
addNamedQueryIfNeeded( current, queries );
}
}
}
if ( queries.size() > 0 ) {
AnnotationDescriptor ad = new AnnotationDescriptor( NamedQueries.class );
- ad.setValue( "value", queries.toArray( new NamedQuery[ queries.size() ] ) );
+ ad.setValue( "value", queries.toArray( new NamedQuery[queries.size()] ) );
return AnnotationFactory.create( ad );
}
else {
@@ -1468,7 +1466,7 @@
if ( annotation != null ) {
String queryName = annotation.name();
boolean present = false;
- for ( NamedQuery current : queries ) {
+ for (NamedQuery current : queries) {
if ( current.name().equals( queryName ) ) {
present = true;
break;
@@ -1485,14 +1483,14 @@
addNamedNativeQueryIfNeeded( annotation, queries );
NamedNativeQueries annotations = getJavaAnnotation( NamedNativeQueries.class );
if ( annotations != null ) {
- for ( NamedNativeQuery current : annotations.value() ) {
+ for (NamedNativeQuery current : annotations.value()) {
addNamedNativeQueryIfNeeded( current, queries );
}
}
}
if ( queries.size() > 0 ) {
AnnotationDescriptor ad = new AnnotationDescriptor( NamedNativeQueries.class );
- ad.setValue( "value", queries.toArray( new NamedNativeQuery[ queries.size() ] ) );
+ ad.setValue( "value", queries.toArray( new NamedNativeQuery[queries.size()] ) );
return AnnotationFactory.create( ad );
}
else {
@@ -1504,7 +1502,7 @@
if ( annotation != null ) {
String queryName = annotation.name();
boolean present = false;
- for ( NamedNativeQuery current : queries ) {
+ for (NamedNativeQuery current : queries) {
if ( current.name().equals( queryName ) ) {
present = true;
break;
@@ -1532,7 +1530,7 @@
ann.setValue( "query", queryElt.getTextTrim() );
List<Element> elements = subelement.elements( "hint" );
List<QueryHint> queryHints = new ArrayList<QueryHint>( elements.size() );
- for ( Element hint : elements ) {
+ for (Element hint : elements) {
AnnotationDescriptor hintDescriptor = new AnnotationDescriptor( QueryHint.class );
String value = hint.attributeValue( "name" );
if ( value == null ) throw new AnnotationException( "<hint> without name. " + SCHEMA_VALIDATION );
@@ -1542,7 +1540,7 @@
hintDescriptor.setValue( "value", value );
queryHints.add( (QueryHint) AnnotationFactory.create( hintDescriptor ) );
}
- ann.setValue( "hints", queryHints.toArray( new QueryHint[ queryHints.size() ] ) );
+ ann.setValue( "hints", queryHints.toArray( new QueryHint[queryHints.size()] ) );
String clazzName = subelement.attributeValue( "result-class" );
if ( StringHelper.isNotEmpty( clazzName ) ) {
Class clazz = null;
@@ -1639,7 +1637,7 @@
}
public static SequenceGenerator buildSequenceGeneratorAnnotation(Element element) {
- if (element != null) {
+ if ( element != null ) {
AnnotationDescriptor ad = new AnnotationDescriptor( SequenceGenerator.class );
copyStringAttribute( ad, element, "name", false );
copyStringAttribute( ad, element, "sequence-name", false );
@@ -1773,7 +1771,7 @@
if ( columns.length == 0 && defaults.canUseJavaAnnotations() ) {
PrimaryKeyJoinColumn annotation = getJavaAnnotation( PrimaryKeyJoinColumn.class );
if ( annotation != null ) {
- columns = new PrimaryKeyJoinColumn[]{annotation};
+ columns = new PrimaryKeyJoinColumn[] { annotation };
}
else {
PrimaryKeyJoinColumns annotations = getJavaAnnotation( PrimaryKeyJoinColumns.class );
@@ -1898,7 +1896,7 @@
new ArrayList<Element>() :
(List<Element>) tree.elements( "secondary-table" );
List<SecondaryTable> secondaryTables = new ArrayList<SecondaryTable>( 3 );
- for ( Element element : elements ) {
+ for (Element element : elements) {
AnnotationDescriptor annotation = new AnnotationDescriptor( SecondaryTable.class );
copyStringAttribute( annotation, element, "name", false );
copyStringAttribute( annotation, element, "catalog", false );
@@ -1924,7 +1922,7 @@
overridesDefaultInSecondaryTable( secTableAnn, defaults, secondaryTables );
SecondaryTables secTablesAnn = getJavaAnnotation( SecondaryTables.class );
if ( secTablesAnn != null ) {
- for ( SecondaryTable table : secTablesAnn.value() ) {
+ for (SecondaryTable table : secTablesAnn.value()) {
overridesDefaultInSecondaryTable( table, defaults, secondaryTables );
}
}
@@ -1970,7 +1968,7 @@
private static void buildUniqueConstraints(AnnotationDescriptor annotation, Element element) {
List uniqueConstraintElementList = element.elements( "unique-constraint" );
- UniqueConstraint[] uniqueConstraints = new UniqueConstraint[ uniqueConstraintElementList.size() ];
+ UniqueConstraint[] uniqueConstraints = new UniqueConstraint[uniqueConstraintElementList.size()];
int ucIndex = 0;
Iterator ucIt = uniqueConstraintElementList.listIterator();
while ( ucIt.hasNext() ) {
@@ -1991,9 +1989,9 @@
}
private PrimaryKeyJoinColumn[] buildPrimaryKeyJoinColumns(Element element) {
- if ( element == null ) return new PrimaryKeyJoinColumn[]{};
+ if ( element == null ) return new PrimaryKeyJoinColumn[] { };
List pkJoinColumnElementList = element.elements( "primary-key-join-column" );
- PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[ pkJoinColumnElementList.size() ];
+ PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[pkJoinColumnElementList.size()];
int index = 0;
Iterator pkIt = pkJoinColumnElementList.listIterator();
while ( pkIt.hasNext() ) {
@@ -2067,15 +2065,15 @@
}
}
- private <T extends Annotation> T getJavaAnnotation(Class<T> annotationType) {
- return element.getAnnotation( annotationType );
- }
+ private <T extends Annotation> T getJavaAnnotation(Class<T> annotationType) {
+ return element.getAnnotation( annotationType );
+ }
- private <T extends Annotation> boolean isJavaAnnotationPresent(Class<T> annotationType) {
- return element.isAnnotationPresent( annotationType );
- }
+ private <T extends Annotation> boolean isJavaAnnotationPresent(Class<T> annotationType) {
+ return element.isAnnotationPresent( annotationType );
+ }
- private Annotation[] getJavaAnnotations() {
- return element.getAnnotations();
- }
+ private Annotation[] getJavaAnnotations() {
+ return element.getAnnotations();
+ }
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3ReflectionManager.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3ReflectionManager.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3ReflectionManager.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -5,7 +5,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import javax.persistence.EntityListeners;
import javax.persistence.NamedNativeQuery;
import javax.persistence.NamedQuery;
@@ -19,84 +18,84 @@
import org.hibernate.util.ReflectHelper;
public class EJB3ReflectionManager extends JavaReflectionManager {
-
- private XMLContext xmlContext = new XMLContext();
- private HashMap defaults = null;
-
- public AnnotationReader buildAnnotationReader(AnnotatedElement annotatedElement) {
- if ( xmlContext.hasContext() ) {
- return new EJB3OverridenAnnotationReader(annotatedElement, xmlContext);
- }
- else {
- return super.buildAnnotationReader(annotatedElement);
- }
- }
- public Map getDefaults() {
- if (defaults == null) {
- defaults = new HashMap();
- XMLContext.Default xmlDefaults = xmlContext.getDefault( null );
- List<Class> entityListeners = new ArrayList<Class>();
- for ( String className : xmlContext.getDefaultEntityListeners() ) {
- try {
- entityListeners.add( ReflectHelper.classForName( className, this.getClass() ) );
- }
- catch (ClassNotFoundException e) {
- throw new IllegalStateException( "Default entity listener class not found: " + className );
- }
- }
- defaults.put( EntityListeners.class, entityListeners );
- for( Element element : xmlContext.getAllDocuments() ) {
+ private XMLContext xmlContext = new XMLContext();
+ private HashMap defaults = null;
- List<Element> elements = element.elements( "sequence-generator" );
- List<SequenceGenerator> sequenceGenerators = (List<SequenceGenerator>) defaults.get(SequenceGenerator.class);
- if (sequenceGenerators == null) {
- sequenceGenerators = new ArrayList<SequenceGenerator>();
- defaults.put( SequenceGenerator.class, sequenceGenerators );
- }
- for (Element subelement : elements) {
- sequenceGenerators.add( EJB3OverridenAnnotationReader.buildSequenceGeneratorAnnotation( subelement ) );
- }
+ public AnnotationReader buildAnnotationReader(AnnotatedElement annotatedElement) {
+ if ( xmlContext.hasContext() ) {
+ return new EJB3OverridenAnnotationReader( annotatedElement, xmlContext );
+ }
+ else {
+ return super.buildAnnotationReader( annotatedElement );
+ }
+ }
- elements = element.elements( "table-generator" );
- List<TableGenerator> tableGenerators = (List<TableGenerator>) defaults.get(TableGenerator.class);
- if (tableGenerators == null) {
- tableGenerators = new ArrayList<TableGenerator>();
- defaults.put( TableGenerator.class, tableGenerators );
- }
- for (Element subelement : elements) {
- tableGenerators.add( EJB3OverridenAnnotationReader.buildTableGeneratorAnnotation( subelement, xmlDefaults ) );
- }
+ public Map getDefaults() {
+ if ( defaults == null ) {
+ defaults = new HashMap();
+ XMLContext.Default xmlDefaults = xmlContext.getDefault( null );
+ List<Class> entityListeners = new ArrayList<Class>();
+ for (String className : xmlContext.getDefaultEntityListeners()) {
+ try {
+ entityListeners.add( ReflectHelper.classForName( className, this.getClass() ) );
+ }
+ catch (ClassNotFoundException e) {
+ throw new IllegalStateException( "Default entity listener class not found: " + className );
+ }
+ }
+ defaults.put( EntityListeners.class, entityListeners );
+ for (Element element : xmlContext.getAllDocuments()) {
- List<NamedQuery> namedQueries = (List<NamedQuery>) defaults.get(NamedQuery.class);
- if (namedQueries == null) {
- namedQueries = new ArrayList<NamedQuery>();
- defaults.put( NamedQuery.class, namedQueries );
- }
- List<NamedQuery> currentNamedQueries = EJB3OverridenAnnotationReader.buildNamedQueries(element, false, xmlDefaults);
- namedQueries.addAll( currentNamedQueries );
+ List<Element> elements = element.elements( "sequence-generator" );
+ List<SequenceGenerator> sequenceGenerators = (List<SequenceGenerator>) defaults.get( SequenceGenerator.class );
+ if ( sequenceGenerators == null ) {
+ sequenceGenerators = new ArrayList<SequenceGenerator>();
+ defaults.put( SequenceGenerator.class, sequenceGenerators );
+ }
+ for (Element subelement : elements) {
+ sequenceGenerators.add( EJB3OverridenAnnotationReader.buildSequenceGeneratorAnnotation( subelement ) );
+ }
- List<NamedNativeQuery> namedNativeQueries = (List<NamedNativeQuery>) defaults.get(NamedNativeQuery.class);
- if (namedNativeQueries == null) {
- namedNativeQueries = new ArrayList<NamedNativeQuery>();
- defaults.put( NamedNativeQuery.class, namedNativeQueries );
- }
- List<NamedNativeQuery> currentNamedNativeQueries = EJB3OverridenAnnotationReader.buildNamedQueries(element, true, xmlDefaults);
- namedNativeQueries.addAll( currentNamedNativeQueries );
+ elements = element.elements( "table-generator" );
+ List<TableGenerator> tableGenerators = (List<TableGenerator>) defaults.get( TableGenerator.class );
+ if ( tableGenerators == null ) {
+ tableGenerators = new ArrayList<TableGenerator>();
+ defaults.put( TableGenerator.class, tableGenerators );
+ }
+ for (Element subelement : elements) {
+ tableGenerators.add( EJB3OverridenAnnotationReader.buildTableGeneratorAnnotation( subelement, xmlDefaults ) );
+ }
- List<SqlResultSetMapping> sqlResultSetMappings = (List<SqlResultSetMapping>) defaults.get(SqlResultSetMapping.class);
- if (sqlResultSetMappings == null) {
- sqlResultSetMappings = new ArrayList<SqlResultSetMapping>();
- defaults.put( SqlResultSetMapping.class, sqlResultSetMappings );
- }
- List<SqlResultSetMapping> currentSqlResultSetMappings = EJB3OverridenAnnotationReader.buildSqlResultsetMappings(element, xmlDefaults);
- sqlResultSetMappings.addAll( currentSqlResultSetMappings );
- }
- }
- return defaults;
- }
+ List<NamedQuery> namedQueries = (List<NamedQuery>) defaults.get( NamedQuery.class );
+ if ( namedQueries == null ) {
+ namedQueries = new ArrayList<NamedQuery>();
+ defaults.put( NamedQuery.class, namedQueries );
+ }
+ List<NamedQuery> currentNamedQueries = EJB3OverridenAnnotationReader.buildNamedQueries( element, false, xmlDefaults );
+ namedQueries.addAll( currentNamedQueries );
- public XMLContext getXMLContext() {
- return xmlContext;
- }
+ List<NamedNativeQuery> namedNativeQueries = (List<NamedNativeQuery>) defaults.get( NamedNativeQuery.class );
+ if ( namedNativeQueries == null ) {
+ namedNativeQueries = new ArrayList<NamedNativeQuery>();
+ defaults.put( NamedNativeQuery.class, namedNativeQueries );
+ }
+ List<NamedNativeQuery> currentNamedNativeQueries = EJB3OverridenAnnotationReader.buildNamedQueries( element, true, xmlDefaults );
+ namedNativeQueries.addAll( currentNamedNativeQueries );
+
+ List<SqlResultSetMapping> sqlResultSetMappings = (List<SqlResultSetMapping>) defaults.get( SqlResultSetMapping.class );
+ if ( sqlResultSetMappings == null ) {
+ sqlResultSetMappings = new ArrayList<SqlResultSetMapping>();
+ defaults.put( SqlResultSetMapping.class, sqlResultSetMappings );
+ }
+ List<SqlResultSetMapping> currentSqlResultSetMappings = EJB3OverridenAnnotationReader.buildSqlResultsetMappings( element, xmlDefaults );
+ sqlResultSetMappings.addAll( currentSqlResultSetMappings );
+ }
+ }
+ return defaults;
+ }
+
+ public XMLContext getXMLContext() {
+ return xmlContext;
+ }
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/XMLContext.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/XMLContext.java 2007-07-19 22:12:04 UTC (rev 12780)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/XMLContext.java 2007-07-19 22:28:14 UTC (rev 12781)
@@ -1,10 +1,10 @@
//$Id: $
package org.hibernate.cfg.annotations.reflection;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.ArrayList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -22,14 +22,14 @@
private Map<String, Default> defaultsOverriding = new HashMap<String, Default>();
private List<Element> defaultElements = new ArrayList<Element>();
private List<String> defaultEntityListeners = new ArrayList<String>();
- private boolean hasContext = false;
+ private boolean hasContext = false;
- /**
+ /**
* Add a document and return the list of added classes names
*/
public List<String> addDocument(Document doc) {
- hasContext = true;
- List<String> addedClasses = new ArrayList<String>();
+ hasContext = true;
+ List<String> addedClasses = new ArrayList<String>();
Element root = doc.getRootElement();
//global defaults
Element metadata = root.element( "persistence-unit-metadata" );
@@ -70,7 +70,7 @@
entityMappingDefault.setCatalog( unitElement != null ? unitElement.getTextTrim() : null );
unitElement = root.element( "access" );
entityMappingDefault.setAccess( unitElement != null ? unitElement.getTextTrim() : null );
- defaultElements.add(root);
+ defaultElements.add( root );
List<Element> entities = (List<Element>) root.elements( "entity" );
addClass( entities, packageName, entityMappingDefault, addedClasses );
@@ -84,7 +84,7 @@
}
private void addClass(List<Element> entities, String packageName, Default defaults, List<String> addedClasses) {
- for ( Element element : entities ) {
+ for (Element element : entities) {
String className = buildSafeClassName( element.attributeValue( "class" ), packageName );
if ( classOverriding.containsKey( className ) ) {
//maybe switch it to warn?
@@ -110,13 +110,13 @@
private List<String> addEntityListenerClasses(Element element, String packageName, List<String> addedClasses) {
List<String> localAddedClasses = new ArrayList<String>();
Element listeners = element.element( "entity-listeners" );
- if (listeners != null) {
+ if ( listeners != null ) {
List<Element> elements = (List<Element>) listeners.elements( "entity-listener" );
- for ( Element listener : elements ) {
+ for (Element listener : elements) {
String listenerClassName = buildSafeClassName( listener.attributeValue( "class" ), packageName );
if ( classOverriding.containsKey( listenerClassName ) ) {
//maybe switch it to warn?
- if ( "entity-listener".equals( classOverriding.get( listenerClassName).getName() ) ) {
+ if ( "entity-listener".equals( classOverriding.get( listenerClassName ).getName() ) ) {
log.info(
"entity-listener duplication, first event definition will be used: "
+ listenerClassName
@@ -150,7 +150,7 @@
public Default getDefault(String className) {
Default xmlDefault = new Default();
xmlDefault.override( globalDefaults );
- if (className != null) {
+ if ( className != null ) {
Default entityMappingOverriding = defaultsOverriding.get( className );
xmlDefault.override( entityMappingOverriding );
}
@@ -165,11 +165,11 @@
return defaultElements;
}
- public boolean hasContext() {
- return hasContext;
- }
+ public boolean hasContext() {
+ return hasContext;
+ }
- public static class Default {
+ public static class Default {
private String access;
private String packageName;
private String schema;
@@ -219,7 +219,7 @@
}
public boolean canUseJavaAnnotations() {
- return metadataComplete == null || ! metadataComplete.booleanValue();
+ return metadataComplete == null || !metadataComplete.booleanValue();
}
protected void setMetadataComplete(Boolean metadataComplete) {
More information about the hibernate-commits
mailing list