HHH-5800 Applying Hibernate code formatting style

This commit is contained in:
Hardy Ferentschik 2011-01-03 16:55:30 +01:00
parent bde29a52d2
commit 95c23b6f50
10 changed files with 290 additions and 198 deletions

View File

@ -1,10 +1,10 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as * Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
* indicated by the @author tags or express copyright attribution * third-party contributors as indicated by either @author tags or express
* statements applied by the authors. All third-party contributions are * copyright attribution statements applied by the authors. All
* distributed under license by Red Hat Inc. * third-party contributions are distributed under license by Red Hat Inc.
* *
* This copyrighted material is made available to anyone wishing to use, modify, * This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU * copy, or redistribute it subject to the terms and conditions of the GNU
@ -51,6 +51,7 @@ import javax.persistence.ColumnResult;
import javax.persistence.DiscriminatorColumn; import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType; import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue; import javax.persistence.DiscriminatorValue;
import javax.persistence.ElementCollection;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
import javax.persistence.Embedded; import javax.persistence.Embedded;
import javax.persistence.EmbeddedId; import javax.persistence.EmbeddedId;
@ -114,10 +115,12 @@ import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.persistence.Version; import javax.persistence.Version;
import javax.persistence.ElementCollection;
import org.dom4j.Attribute; import org.dom4j.Attribute;
import org.dom4j.Element; import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.annotations.Cascade; import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CollectionOfElements; import org.hibernate.annotations.CollectionOfElements;
@ -129,8 +132,6 @@ import org.hibernate.annotations.common.reflection.Filter;
import org.hibernate.annotations.common.reflection.ReflectionUtil; import org.hibernate.annotations.common.reflection.ReflectionUtil;
import org.hibernate.util.ReflectHelper; import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper; import org.hibernate.util.StringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Encapsulates the overriding of Java annotations from an EJB 3.0 descriptor. * Encapsulates the overriding of Java annotations from an EJB 3.0 descriptor.
@ -260,7 +261,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
try { try {
mirroredAttribute = field.getDeclaringClass().getDeclaredMethod( expectedGetter ); mirroredAttribute = field.getDeclaringClass().getDeclaredMethod( expectedGetter );
} }
catch (NoSuchMethodException e) { catch ( NoSuchMethodException e ) {
//no method //no method
} }
} }
@ -286,7 +287,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
try { try {
mirroredAttribute = method.getDeclaringClass().getDeclaredField( propertyName ); mirroredAttribute = method.getDeclaringClass().getDeclaredField( propertyName );
} }
catch (NoSuchFieldException e) { catch ( NoSuchFieldException e ) {
//no method //no method
} }
} }
@ -328,7 +329,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
Annotation[] annotations = getJavaAnnotations(); Annotation[] annotations = getJavaAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 ); List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 );
annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 ); annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
for (Annotation annotation : annotations) { for ( Annotation annotation : annotations ) {
if ( !annotationToXml.containsKey( annotation.annotationType() ) ) { if ( !annotationToXml.containsKey( annotation.annotationType() ) ) {
//unknown annotations are left over //unknown annotations are left over
annotationList.add( annotation ); annotationList.add( annotation );
@ -355,9 +356,8 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
addIfNotNull( annotationList, getAttributeOverrides( tree, defaults, true ) ); addIfNotNull( annotationList, getAttributeOverrides( tree, defaults, true ) );
addIfNotNull( annotationList, getAssociationOverrides( tree, defaults, true ) ); addIfNotNull( annotationList, getAssociationOverrides( tree, defaults, true ) );
addIfNotNull( annotationList, getEntityListeners( 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()] ); this.annotations = annotationList.toArray( new Annotation[annotationList.size()] );
for (Annotation ann : this.annotations) { for ( Annotation ann : this.annotations ) {
annotationsMap.put( ann.annotationType(), ann ); annotationsMap.put( ann.annotationType(), ann );
} }
checkForOrphanProperties( tree ); checkForOrphanProperties( tree );
@ -367,7 +367,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
Annotation[] annotations = getJavaAnnotations(); Annotation[] annotations = getJavaAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 ); List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 );
annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 ); annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
for (Annotation annotation : annotations) { for ( Annotation annotation : annotations ) {
if ( !annotationToXml.containsKey( annotation.annotationType() ) ) { if ( !annotationToXml.containsKey( annotation.annotationType() ) ) {
//unknown annotations are left over //unknown annotations are left over
annotationList.add( annotation ); annotationList.add( annotation );
@ -399,14 +399,14 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
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 //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()] ); this.annotations = annotationList.toArray( new Annotation[annotationList.size()] );
for (Annotation ann : this.annotations) { for ( Annotation ann : this.annotations ) {
annotationsMap.put( ann.annotationType(), ann ); annotationsMap.put( ann.annotationType(), ann );
} }
} }
else { else {
this.annotations = getJavaAnnotations(); this.annotations = getJavaAnnotations();
annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 ); annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
for (Annotation ann : this.annotations) { for ( Annotation ann : this.annotations ) {
annotationsMap.put( ann.annotationType(), ann ); annotationsMap.put( ann.annotationType(), ann );
} }
} }
@ -418,7 +418,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
try { try {
clazz = ReflectHelper.classForName( className, this.getClass() ); clazz = ReflectHelper.classForName( className, this.getClass() );
} }
catch (ClassNotFoundException e) { catch ( ClassNotFoundException e ) {
return; //a primitive type most likely return; //a primitive type most likely
} }
Element element = tree != null ? tree.element( "attributes" ) : null; Element element = tree != null ? tree.element( "attributes" ) : null;
@ -427,10 +427,10 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
//precompute the list of properties //precompute the list of properties
//TODO is it really useful... //TODO is it really useful...
Set<String> properties = new HashSet<String>(); Set<String> properties = new HashSet<String>();
for (Field field : clazz.getFields()) { for ( Field field : clazz.getFields() ) {
properties.add( field.getName() ); properties.add( field.getName() );
} }
for (Method method : clazz.getMethods()) { for ( Method method : clazz.getMethods() ) {
String name = method.getName(); String name = method.getName();
if ( name.startsWith( "get" ) ) { if ( name.startsWith( "get" ) ) {
properties.add( Introspector.decapitalize( name.substring( "get".length() ) ) ); properties.add( Introspector.decapitalize( name.substring( "get".length() ) ) );
@ -439,12 +439,14 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
properties.add( Introspector.decapitalize( name.substring( "is".length() ) ) ); 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" ); String propertyName = subelement.attributeValue( "name" );
if ( !properties.contains( propertyName ) ) { if ( !properties.contains( propertyName ) ) {
log.warn( "Property {} not found in class" log.warn(
+ " but described in <mapping-file/> (possible typo error)", "Property {} not found in class"
StringHelper.qualify( className, propertyName ) ); + " but described in <mapping-file/> (possible typo error)",
StringHelper.qualify( className, propertyName )
);
} }
} }
} }
@ -467,7 +469,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
//TODO mutualize the next 2 methods //TODO mutualize the next 2 methods
private Annotation getTableGenerator(List<Element> elementsForProperty, XMLContext.Default defaults) { private Annotation getTableGenerator(List<Element> elementsForProperty, XMLContext.Default defaults) {
for (Element element : elementsForProperty) { for ( Element element : elementsForProperty ) {
Element subelement = element != null ? element.element( annotationToXml.get( TableGenerator.class ) ) : null; Element subelement = element != null ? element.element( annotationToXml.get( TableGenerator.class ) ) : null;
if ( subelement != null ) { if ( subelement != null ) {
return buildTableGeneratorAnnotation( subelement, defaults ); return buildTableGeneratorAnnotation( subelement, defaults );
@ -482,7 +484,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
private Annotation getSequenceGenerator(List<Element> elementsForProperty, XMLContext.Default defaults) { private Annotation getSequenceGenerator(List<Element> elementsForProperty, XMLContext.Default defaults) {
for (Element element : elementsForProperty) { for ( Element element : elementsForProperty ) {
Element subelement = element != null ? element.element( annotationToXml.get( SequenceGenerator.class ) ) : null; Element subelement = element != null ? element.element( annotationToXml.get( SequenceGenerator.class ) ) : null;
if ( subelement != null ) { if ( subelement != null ) {
return buildSequenceGeneratorAnnotation( subelement ); return buildSequenceGeneratorAnnotation( subelement );
@ -498,7 +500,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
private void processEventAnnotations(List<Annotation> annotationList, XMLContext.Default defaults) { private void processEventAnnotations(List<Annotation> annotationList, XMLContext.Default defaults) {
boolean eventElement = false; boolean eventElement = false;
for (Element element : elementsForProperty) { for ( Element element : elementsForProperty ) {
String elementName = element.getName(); String elementName = element.getName();
if ( "pre-persist".equals( elementName ) ) { if ( "pre-persist".equals( elementName ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( PrePersist.class ); AnnotationDescriptor ad = new AnnotationDescriptor( PrePersist.class );
@ -558,7 +560,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
Element element = tree != null ? tree.element( "entity-listeners" ) : null; Element element = tree != null ? tree.element( "entity-listeners" ) : null;
if ( element != null ) { if ( element != null ) {
List<Class> entityListenerClasses = new ArrayList<Class>(); 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" ); String className = subelement.attributeValue( "class" );
try { try {
entityListenerClasses.add( entityListenerClasses.add(
@ -568,7 +570,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
) )
); );
} }
catch (ClassNotFoundException e) { catch ( ClassNotFoundException e ) {
throw new AnnotationException( throw new AnnotationException(
"Unable to find " + element.getPath() + ".class: " + className, e "Unable to find " + element.getPath() + ".class: " + className, e
); );
@ -676,7 +678,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
Class<? extends Annotation> annotationType, List<Annotation> annotationList, XMLContext.Default defaults Class<? extends Annotation> annotationType, List<Annotation> annotationList, XMLContext.Default defaults
) { ) {
String xmlName = annotationToXml.get( annotationType ); String xmlName = annotationToXml.get( annotationType );
for (Element element : elementsForProperty) { for ( Element element : elementsForProperty ) {
if ( xmlName.equals( element.getName() ) ) { if ( xmlName.equals( element.getName() ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( annotationType ); AnnotationDescriptor ad = new AnnotationDescriptor( annotationType );
addTargetClass( element, ad, "target-entity", defaults ); addTargetClass( element, ad, "target-entity", defaults );
@ -848,7 +850,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
List<Element> subelements = element != null ? element.elements( "map-key-join-column" ) : null; List<Element> subelements = element != null ? element.elements( "map-key-join-column" ) : null;
List<MapKeyJoinColumn> joinColumns = new ArrayList<MapKeyJoinColumn>(); List<MapKeyJoinColumn> joinColumns = new ArrayList<MapKeyJoinColumn>();
if ( subelements != null ) { if ( subelements != null ) {
for (Element subelement : subelements) { for ( Element subelement : subelements ) {
AnnotationDescriptor column = new AnnotationDescriptor( MapKeyJoinColumn.class ); AnnotationDescriptor column = new AnnotationDescriptor( MapKeyJoinColumn.class );
copyStringAttribute( column, subelement, "name", false ); copyStringAttribute( column, subelement, "name", false );
copyStringAttribute( column, subelement, "referenced-column-name", false ); copyStringAttribute( column, subelement, "referenced-column-name", false );
@ -953,7 +955,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
XMLContext.buildSafeClassName( className, defaults ), this.getClass() XMLContext.buildSafeClassName( className, defaults ), this.getClass()
); );
} }
catch (ClassNotFoundException e) { catch ( ClassNotFoundException e ) {
throw new AnnotationException( throw new AnnotationException(
"Unable to find " + element.getPath() + " " + nodeName + ": " + className, e "Unable to find " + element.getPath() + " " + nodeName + ": " + className, e
); );
@ -1051,11 +1053,11 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
Class clazz; Class clazz;
try { try {
clazz = ReflectHelper.classForName( clazz = ReflectHelper.classForName(
XMLContext.buildSafeClassName(mapKeyClassName, defaults ), XMLContext.buildSafeClassName( mapKeyClassName, defaults ),
this.getClass() this.getClass()
); );
} }
catch (ClassNotFoundException e) { catch ( ClassNotFoundException e ) {
throw new AnnotationException( throw new AnnotationException(
"Unable to find " + element.getPath() + " " + nodeName + ": " + mapKeyClassName, e "Unable to find " + element.getPath() + " " + nodeName + ": " + mapKeyClassName, e
); );
@ -1102,13 +1104,25 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
private void getCascades(AnnotationDescriptor ad, Element element, XMLContext.Default defaults) { private void getCascades(AnnotationDescriptor ad, Element element, XMLContext.Default defaults) {
List<Element> elements = element != null ? element.elements( "cascade" ) : new ArrayList<Element>( 0 ); List<Element> elements = element != null ? element.elements( "cascade" ) : new ArrayList<Element>( 0 );
List<CascadeType> cascades = new ArrayList<CascadeType>(); 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-all" ) != null ) {
if ( subelement.element( "cascade-persist" ) != null ) cascades.add( CascadeType.PERSIST ); cascades.add( CascadeType.ALL );
if ( subelement.element( "cascade-merge" ) != null ) cascades.add( CascadeType.MERGE ); }
if ( subelement.element( "cascade-remove" ) != null ) cascades.add( CascadeType.REMOVE ); if ( subelement.element( "cascade-persist" ) != null ) {
if ( subelement.element( "cascade-refresh" ) != null ) cascades.add( CascadeType.REFRESH ); cascades.add( CascadeType.PERSIST );
if ( subelement.element( "cascade-detach" ) != null ) cascades.add( CascadeType.DETACH ); }
if ( subelement.element( "cascade-merge" ) != null ) {
cascades.add( CascadeType.MERGE );
}
if ( subelement.element( "cascade-remove" ) != null ) {
cascades.add( CascadeType.REMOVE );
}
if ( subelement.element( "cascade-refresh" ) != null ) {
cascades.add( CascadeType.REFRESH );
}
if ( subelement.element( "cascade-detach" ) != null ) {
cascades.add( CascadeType.DETACH );
}
} }
if ( Boolean.TRUE.equals( defaults.getCascadePersist() ) if ( Boolean.TRUE.equals( defaults.getCascadePersist() )
&& !cascades.contains( CascadeType.ALL ) && !cascades.contains( CascadeType.PERSIST ) ) { && !cascades.contains( CascadeType.ALL ) && !cascades.contains( CascadeType.PERSIST ) ) {
@ -1120,7 +1134,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
private void getEmbedded(List<Annotation> annotationList, XMLContext.Default defaults) { private void getEmbedded(List<Annotation> annotationList, XMLContext.Default defaults) {
for (Element element : elementsForProperty) { for ( Element element : elementsForProperty ) {
if ( "embedded".equals( element.getName() ) ) { if ( "embedded".equals( element.getName() ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( Embedded.class ); AnnotationDescriptor ad = new AnnotationDescriptor( Embedded.class );
annotationList.add( AnnotationFactory.create( ad ) ); annotationList.add( AnnotationFactory.create( ad ) );
@ -1148,7 +1162,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
private Transient getTransient(XMLContext.Default defaults) { private Transient getTransient(XMLContext.Default defaults) {
for (Element element : elementsForProperty) { for ( Element element : elementsForProperty ) {
if ( "transient".equals( element.getName() ) ) { if ( "transient".equals( element.getName() ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( Transient.class ); AnnotationDescriptor ad = new AnnotationDescriptor( Transient.class );
return AnnotationFactory.create( ad ); return AnnotationFactory.create( ad );
@ -1163,7 +1177,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
private void getVersion(List<Annotation> annotationList, XMLContext.Default defaults) { private void getVersion(List<Annotation> annotationList, XMLContext.Default defaults) {
for (Element element : elementsForProperty) { for ( Element element : elementsForProperty ) {
if ( "version".equals( element.getName() ) ) { if ( "version".equals( element.getName() ) ) {
Annotation annotation = buildColumns( element ); Annotation annotation = buildColumns( element );
addIfNotNull( annotationList, annotation ); addIfNotNull( annotationList, annotation );
@ -1189,7 +1203,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
private void getBasic(List<Annotation> annotationList, XMLContext.Default defaults) { private void getBasic(List<Annotation> annotationList, XMLContext.Default defaults) {
for (Element element : elementsForProperty) { for ( Element element : elementsForProperty ) {
if ( "basic".equals( element.getName() ) ) { if ( "basic".equals( element.getName() ) ) {
Annotation annotation = buildColumns( element ); Annotation annotation = buildColumns( element );
addIfNotNull( annotationList, annotation ); addIfNotNull( annotationList, annotation );
@ -1266,7 +1280,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
private void getEmbeddedId(List<Annotation> annotationList, XMLContext.Default defaults) { private void getEmbeddedId(List<Annotation> annotationList, XMLContext.Default defaults) {
for (Element element : elementsForProperty) { for ( Element element : elementsForProperty ) {
if ( "embedded-id".equals( element.getName() ) ) { if ( "embedded-id".equals( element.getName() ) ) {
if ( isProcessingId( defaults ) ) { if ( isProcessingId( defaults ) ) {
Annotation annotation = getAttributeOverrides( element, defaults, false ); Annotation annotation = getAttributeOverrides( element, defaults, false );
@ -1312,7 +1326,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
Element element = tree != null ? tree.element( "attributes" ) : null; Element element = tree != null ? tree.element( "attributes" ) : null;
//put entity.attributes elements //put entity.attributes elements
if ( element != null ) { if ( element != null ) {
for (Element subelement : (List<Element>) element.elements()) { for ( Element subelement : (List<Element>) element.elements() ) {
if ( propertyName.equals( subelement.attributeValue( "name" ) ) ) { if ( propertyName.equals( subelement.attributeValue( "name" ) ) ) {
elementsForProperty.add( subelement ); elementsForProperty.add( subelement );
} }
@ -1320,7 +1334,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
//add pre-* etc from entity and pure entity listener classes //add pre-* etc from entity and pure entity listener classes
if ( tree != null ) { if ( tree != null ) {
for (Element subelement : (List<Element>) tree.elements()) { for ( Element subelement : (List<Element>) tree.elements() ) {
if ( propertyName.equals( subelement.attributeValue( "method-name" ) ) ) { if ( propertyName.equals( subelement.attributeValue( "method-name" ) ) ) {
elementsForProperty.add( subelement ); elementsForProperty.add( subelement );
} }
@ -1329,7 +1343,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
private void getId(List<Annotation> annotationList, XMLContext.Default defaults) { private void getId(List<Annotation> annotationList, XMLContext.Default defaults) {
for (Element element : elementsForProperty) { for ( Element element : elementsForProperty ) {
if ( "id".equals( element.getName() ) ) { if ( "id".equals( element.getName() ) ) {
boolean processId = isProcessingId( defaults ); boolean processId = isProcessingId( defaults );
if ( processId ) { if ( processId ) {
@ -1381,7 +1395,8 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
boolean isExplicit = defaults.getAccess() != null; boolean isExplicit = defaults.getAccess() != null;
boolean correctAccess = boolean correctAccess =
( PropertyType.PROPERTY.equals( propertyType ) && AccessType.PROPERTY.equals( defaults.getAccess() ) ) ( PropertyType.PROPERTY.equals( propertyType ) && AccessType.PROPERTY.equals( defaults.getAccess() ) )
|| ( PropertyType.FIELD.equals( propertyType ) && AccessType.FIELD.equals( defaults.getAccess() ) ); || ( PropertyType.FIELD.equals( propertyType ) && AccessType.FIELD
.equals( defaults.getAccess() ) );
boolean hasId = defaults.canUseJavaAnnotations() boolean hasId = defaults.canUseJavaAnnotations()
&& ( isJavaAnnotationPresent( Id.class ) || isJavaAnnotationPresent( EmbeddedId.class ) ); && ( isJavaAnnotationPresent( Id.class ) || isJavaAnnotationPresent( EmbeddedId.class ) );
//if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) { //if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) {
@ -1397,7 +1412,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
private Columns buildColumns(Element element) { private Columns buildColumns(Element element) {
List<Element> subelements = element.elements( "column" ); List<Element> subelements = element.elements( "column" );
List<Column> columns = new ArrayList<Column>( subelements.size() ); List<Column> columns = new ArrayList<Column>( subelements.size() );
for (Element subelement : subelements) { for ( Element subelement : subelements ) {
columns.add( getColumn( subelement, false, element ) ); columns.add( getColumn( subelement, false, element ) );
} }
if ( columns.size() > 0 ) { if ( columns.size() > 0 ) {
@ -1486,9 +1501,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
/** /**
* @param mergeWithAnnotations Whether to use Java annotations for this * @param mergeWithAnnotations Whether to use Java annotations for this
* element, if present and not disabled by the XMLContext defaults. * element, if present and not disabled by the XMLContext defaults.
* In some contexts (such as an element-collection mapping) merging * In some contexts (such as an element-collection mapping) merging
* with annotations is never allowed. * with annotations is never allowed.
*/ */
private AssociationOverrides getAssociationOverrides(Element tree, XMLContext.Default defaults, boolean mergeWithAnnotations) { private AssociationOverrides getAssociationOverrides(Element tree, XMLContext.Default defaults, boolean mergeWithAnnotations) {
List<AssociationOverride> attributes = buildAssociationOverrides( tree, defaults ); List<AssociationOverride> attributes = buildAssociationOverrides( tree, defaults );
@ -1497,7 +1512,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
addAssociationOverrideIfNeeded( annotation, attributes ); addAssociationOverrideIfNeeded( annotation, attributes );
AssociationOverrides annotations = getJavaAnnotation( AssociationOverrides.class ); AssociationOverrides annotations = getJavaAnnotation( AssociationOverrides.class );
if ( annotations != null ) { if ( annotations != null ) {
for (AssociationOverride current : annotations.value()) { for ( AssociationOverride current : annotations.value() ) {
addAssociationOverrideIfNeeded( current, attributes ); addAssociationOverrideIfNeeded( current, attributes );
} }
} }
@ -1512,11 +1527,11 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
} }
private List<AssociationOverride> buildAssociationOverrides(Element element, XMLContext.Default defaults ) { private List<AssociationOverride> buildAssociationOverrides(Element element, XMLContext.Default defaults) {
List<Element> subelements = element == null ? null : element.elements( "association-override" ); List<Element> subelements = element == null ? null : element.elements( "association-override" );
List<AssociationOverride> overrides = new ArrayList<AssociationOverride>(); List<AssociationOverride> overrides = new ArrayList<AssociationOverride>();
if ( subelements != null && subelements.size() > 0 ) { if ( subelements != null && subelements.size() > 0 ) {
for (Element current : subelements) { for ( Element current : subelements ) {
AnnotationDescriptor override = new AnnotationDescriptor( AssociationOverride.class ); AnnotationDescriptor override = new AnnotationDescriptor( AssociationOverride.class );
copyStringAttribute( override, current, "name", true ); copyStringAttribute( override, current, "name", true );
override.setValue( "joinColumns", getJoinColumns( current, false ) ); override.setValue( "joinColumns", getJoinColumns( current, false ) );
@ -1536,7 +1551,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
null; null;
List<JoinColumn> joinColumns = new ArrayList<JoinColumn>(); List<JoinColumn> joinColumns = new ArrayList<JoinColumn>();
if ( subelements != null ) { if ( subelements != null ) {
for (Element subelement : subelements) { for ( Element subelement : subelements ) {
AnnotationDescriptor column = new AnnotationDescriptor( JoinColumn.class ); AnnotationDescriptor column = new AnnotationDescriptor( JoinColumn.class );
copyStringAttribute( column, subelement, "name", false ); copyStringAttribute( column, subelement, "name", false );
copyStringAttribute( column, subelement, "referenced-column-name", false ); copyStringAttribute( column, subelement, "referenced-column-name", false );
@ -1556,21 +1571,23 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
if ( annotation != null ) { if ( annotation != null ) {
String overrideName = annotation.name(); String overrideName = annotation.name();
boolean present = false; boolean present = false;
for (AssociationOverride current : overrides) { for ( AssociationOverride current : overrides ) {
if ( current.name().equals( overrideName ) ) { if ( current.name().equals( overrideName ) ) {
present = true; present = true;
break; break;
} }
} }
if ( !present ) overrides.add( annotation ); if ( !present ) {
overrides.add( annotation );
}
} }
} }
/** /**
* @param mergeWithAnnotations Whether to use Java annotations for this * @param mergeWithAnnotations Whether to use Java annotations for this
* element, if present and not disabled by the XMLContext defaults. * element, if present and not disabled by the XMLContext defaults.
* In some contexts (such as an association mapping) merging with * In some contexts (such as an association mapping) merging with
* annotations is never allowed. * annotations is never allowed.
*/ */
private AttributeOverrides getAttributeOverrides(Element tree, XMLContext.Default defaults, boolean mergeWithAnnotations) { private AttributeOverrides getAttributeOverrides(Element tree, XMLContext.Default defaults, boolean mergeWithAnnotations) {
List<AttributeOverride> attributes = buildAttributeOverrides( tree, "attribute-override" ); List<AttributeOverride> attributes = buildAttributeOverrides( tree, "attribute-override" );
@ -1579,9 +1596,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
/** /**
* @param mergeWithAnnotations Whether to use Java annotations for this * @param mergeWithAnnotations Whether to use Java annotations for this
* element, if present and not disabled by the XMLContext defaults. * element, if present and not disabled by the XMLContext defaults.
* In some contexts (such as an association mapping) merging with * In some contexts (such as an association mapping) merging with
* annotations is never allowed. * annotations is never allowed.
*/ */
private AttributeOverrides mergeAttributeOverrides(XMLContext.Default defaults, List<AttributeOverride> attributes, boolean mergeWithAnnotations) { private AttributeOverrides mergeAttributeOverrides(XMLContext.Default defaults, List<AttributeOverride> attributes, boolean mergeWithAnnotations) {
if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) { if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) {
@ -1589,7 +1606,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
addAttributeOverrideIfNeeded( annotation, attributes ); addAttributeOverrideIfNeeded( annotation, attributes );
AttributeOverrides annotations = getJavaAnnotation( AttributeOverrides.class ); AttributeOverrides annotations = getJavaAnnotation( AttributeOverrides.class );
if ( annotations != null ) { if ( annotations != null ) {
for (AttributeOverride current : annotations.value()) { for ( AttributeOverride current : annotations.value() ) {
addAttributeOverrideIfNeeded( current, attributes ); addAttributeOverrideIfNeeded( current, attributes );
} }
} }
@ -1612,8 +1629,10 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
private List<AttributeOverride> buildAttributeOverrides(List<Element> subelements, String nodeName) { private List<AttributeOverride> buildAttributeOverrides(List<Element> subelements, String nodeName) {
List<AttributeOverride> overrides = new ArrayList<AttributeOverride>(); List<AttributeOverride> overrides = new ArrayList<AttributeOverride>();
if ( subelements != null && subelements.size() > 0 ) { if ( subelements != null && subelements.size() > 0 ) {
for (Element current : subelements) { for ( Element current : subelements ) {
if ( !current.getName().equals( nodeName ) ) continue; if ( !current.getName().equals( nodeName ) ) {
continue;
}
AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class ); AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class );
copyStringAttribute( override, current, "name", true ); copyStringAttribute( override, current, "name", true );
Element column = current.element( "column" ); Element column = current.element( "column" );
@ -1652,13 +1671,15 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
if ( annotation != null ) { if ( annotation != null ) {
String overrideName = annotation.name(); String overrideName = annotation.name();
boolean present = false; boolean present = false;
for (AttributeOverride current : overrides) { for ( AttributeOverride current : overrides ) {
if ( current.name().equals( overrideName ) ) { if ( current.name().equals( overrideName ) ) {
present = true; present = true;
break; break;
} }
} }
if ( !present ) overrides.add( annotation ); if ( !present ) {
overrides.add( annotation );
}
} }
} }
@ -1720,7 +1741,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
addSqlResultsetMappingIfNeeded( annotation, results ); addSqlResultsetMappingIfNeeded( annotation, results );
SqlResultSetMappings annotations = getJavaAnnotation( SqlResultSetMappings.class ); SqlResultSetMappings annotations = getJavaAnnotation( SqlResultSetMappings.class );
if ( annotations != null ) { if ( annotations != null ) {
for (SqlResultSetMapping current : annotations.value()) { for ( SqlResultSetMapping current : annotations.value() ) {
addSqlResultsetMappingIfNeeded( current, results ); addSqlResultsetMappingIfNeeded( current, results );
} }
} }
@ -1736,7 +1757,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
public static List<SqlResultSetMapping> buildSqlResultsetMappings(Element element, XMLContext.Default defaults) { public static List<SqlResultSetMapping> buildSqlResultsetMappings(Element element, XMLContext.Default defaults) {
if ( element == null ) return new ArrayList<SqlResultSetMapping>(); if ( element == null ) {
return new ArrayList<SqlResultSetMapping>();
}
List resultsetElementList = element.elements( "sql-result-set-mapping" ); List resultsetElementList = element.elements( "sql-result-set-mapping" );
List<SqlResultSetMapping> resultsets = new ArrayList<SqlResultSetMapping>(); List<SqlResultSetMapping> resultsets = new ArrayList<SqlResultSetMapping>();
Iterator it = resultsetElementList.listIterator(); Iterator it = resultsetElementList.listIterator();
@ -1746,7 +1769,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
copyStringAttribute( ann, subelement, "name", true ); copyStringAttribute( ann, subelement, "name", true );
List<Element> elements = subelement.elements( "entity-result" ); List<Element> elements = subelement.elements( "entity-result" );
List<EntityResult> entityResults = new ArrayList<EntityResult>( elements.size() ); List<EntityResult> entityResults = new ArrayList<EntityResult>( elements.size() );
for (Element entityResult : elements) { for ( Element entityResult : elements ) {
AnnotationDescriptor entityResultDescriptor = new AnnotationDescriptor( EntityResult.class ); AnnotationDescriptor entityResultDescriptor = new AnnotationDescriptor( EntityResult.class );
String clazzName = entityResult.attributeValue( "entity-class" ); String clazzName = entityResult.attributeValue( "entity-class" );
if ( clazzName == null ) { if ( clazzName == null ) {
@ -1759,13 +1782,13 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
JPAOverridenAnnotationReader.class JPAOverridenAnnotationReader.class
); );
} }
catch (ClassNotFoundException e) { catch ( ClassNotFoundException e ) {
throw new AnnotationException( "Unable to find entity-class: " + clazzName, e ); throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
} }
entityResultDescriptor.setValue( "entityClass", clazz ); entityResultDescriptor.setValue( "entityClass", clazz );
copyStringAttribute( entityResultDescriptor, entityResult, "discriminator-column", false ); copyStringAttribute( entityResultDescriptor, entityResult, "discriminator-column", false );
List<FieldResult> fieldResults = new ArrayList<FieldResult>(); 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 ); AnnotationDescriptor fieldResultDescriptor = new AnnotationDescriptor( FieldResult.class );
copyStringAttribute( fieldResultDescriptor, fieldResult, "name", true ); copyStringAttribute( fieldResultDescriptor, fieldResult, "name", true );
copyStringAttribute( fieldResultDescriptor, fieldResult, "column", true ); copyStringAttribute( fieldResultDescriptor, fieldResult, "column", true );
@ -1780,7 +1803,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
elements = subelement.elements( "column-result" ); elements = subelement.elements( "column-result" );
List<ColumnResult> columnResults = new ArrayList<ColumnResult>( elements.size() ); List<ColumnResult> columnResults = new ArrayList<ColumnResult>( elements.size() );
for (Element columnResult : elements) { for ( Element columnResult : elements ) {
AnnotationDescriptor columnResultDescriptor = new AnnotationDescriptor( ColumnResult.class ); AnnotationDescriptor columnResultDescriptor = new AnnotationDescriptor( ColumnResult.class );
copyStringAttribute( columnResultDescriptor, columnResult, "name", true ); copyStringAttribute( columnResultDescriptor, columnResult, "name", true );
columnResults.add( (ColumnResult) AnnotationFactory.create( columnResultDescriptor ) ); columnResults.add( (ColumnResult) AnnotationFactory.create( columnResultDescriptor ) );
@ -1792,11 +1815,11 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
Class clazz; Class clazz;
try { try {
clazz = ReflectHelper.classForName( clazz = ReflectHelper.classForName(
XMLContext.buildSafeClassName( clazzName, defaults ), XMLContext.buildSafeClassName( clazzName, defaults ),
JPAOverridenAnnotationReader.class JPAOverridenAnnotationReader.class
); );
} }
catch (ClassNotFoundException e) { catch ( ClassNotFoundException e ) {
throw new AnnotationException( "Unable to find entity-class: " + clazzName, e ); throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
} }
ann.setValue( "resultClass", clazz ); ann.setValue( "resultClass", clazz );
@ -1811,13 +1834,15 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
if ( annotation != null ) { if ( annotation != null ) {
String resultsetName = annotation.name(); String resultsetName = annotation.name();
boolean present = false; boolean present = false;
for (SqlResultSetMapping current : resultsets) { for ( SqlResultSetMapping current : resultsets ) {
if ( current.name().equals( resultsetName ) ) { if ( current.name().equals( resultsetName ) ) {
present = true; present = true;
break; break;
} }
} }
if ( !present ) resultsets.add( annotation ); if ( !present ) {
resultsets.add( annotation );
}
} }
} }
@ -1829,7 +1854,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
addNamedQueryIfNeeded( annotation, queries ); addNamedQueryIfNeeded( annotation, queries );
NamedQueries annotations = getJavaAnnotation( NamedQueries.class ); NamedQueries annotations = getJavaAnnotation( NamedQueries.class );
if ( annotations != null ) { if ( annotations != null ) {
for (NamedQuery current : annotations.value()) { for ( NamedQuery current : annotations.value() ) {
addNamedQueryIfNeeded( current, queries ); addNamedQueryIfNeeded( current, queries );
} }
} }
@ -1848,13 +1873,15 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
if ( annotation != null ) { if ( annotation != null ) {
String queryName = annotation.name(); String queryName = annotation.name();
boolean present = false; boolean present = false;
for (NamedQuery current : queries) { for ( NamedQuery current : queries ) {
if ( current.name().equals( queryName ) ) { if ( current.name().equals( queryName ) ) {
present = true; present = true;
break; break;
} }
} }
if ( !present ) queries.add( annotation ); if ( !present ) {
queries.add( annotation );
}
} }
} }
@ -1865,7 +1892,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
addNamedNativeQueryIfNeeded( annotation, queries ); addNamedNativeQueryIfNeeded( annotation, queries );
NamedNativeQueries annotations = getJavaAnnotation( NamedNativeQueries.class ); NamedNativeQueries annotations = getJavaAnnotation( NamedNativeQueries.class );
if ( annotations != null ) { if ( annotations != null ) {
for (NamedNativeQuery current : annotations.value()) { for ( NamedNativeQuery current : annotations.value() ) {
addNamedNativeQueryIfNeeded( current, queries ); addNamedNativeQueryIfNeeded( current, queries );
} }
} }
@ -1884,18 +1911,22 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
if ( annotation != null ) { if ( annotation != null ) {
String queryName = annotation.name(); String queryName = annotation.name();
boolean present = false; boolean present = false;
for (NamedNativeQuery current : queries) { for ( NamedNativeQuery current : queries ) {
if ( current.name().equals( queryName ) ) { if ( current.name().equals( queryName ) ) {
present = true; present = true;
break; break;
} }
} }
if ( !present ) queries.add( annotation ); if ( !present ) {
queries.add( annotation );
}
} }
} }
public static List buildNamedQueries(Element element, boolean isNative, XMLContext.Default defaults) { public static List buildNamedQueries(Element element, boolean isNative, XMLContext.Default defaults) {
if ( element == null ) return new ArrayList(); if ( element == null ) {
return new ArrayList();
}
List namedQueryElementList = isNative ? List namedQueryElementList = isNative ?
element.elements( "named-native-query" ) : element.elements( "named-native-query" ) :
element.elements( "named-query" ); element.elements( "named-query" );
@ -1908,17 +1939,23 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
); );
copyStringAttribute( ann, subelement, "name", false ); copyStringAttribute( ann, subelement, "name", false );
Element queryElt = subelement.element( "query" ); Element queryElt = subelement.element( "query" );
if ( queryElt == null ) throw new AnnotationException( "No <query> element found." + SCHEMA_VALIDATION ); if ( queryElt == null ) {
throw new AnnotationException( "No <query> element found." + SCHEMA_VALIDATION );
}
copyStringElement( queryElt, ann, "query" ); copyStringElement( queryElt, ann, "query" );
List<Element> elements = subelement.elements( "hint" ); List<Element> elements = subelement.elements( "hint" );
List<QueryHint> queryHints = new ArrayList<QueryHint>( elements.size() ); List<QueryHint> queryHints = new ArrayList<QueryHint>( elements.size() );
for (Element hint : elements) { for ( Element hint : elements ) {
AnnotationDescriptor hintDescriptor = new AnnotationDescriptor( QueryHint.class ); AnnotationDescriptor hintDescriptor = new AnnotationDescriptor( QueryHint.class );
String value = hint.attributeValue( "name" ); String value = hint.attributeValue( "name" );
if ( value == null ) throw new AnnotationException( "<hint> without name. " + SCHEMA_VALIDATION ); if ( value == null ) {
throw new AnnotationException( "<hint> without name. " + SCHEMA_VALIDATION );
}
hintDescriptor.setValue( "name", value ); hintDescriptor.setValue( "name", value );
value = hint.attributeValue( "value" ); value = hint.attributeValue( "value" );
if ( value == null ) throw new AnnotationException( "<hint> without value. " + SCHEMA_VALIDATION ); if ( value == null ) {
throw new AnnotationException( "<hint> without value. " + SCHEMA_VALIDATION );
}
hintDescriptor.setValue( "value", value ); hintDescriptor.setValue( "value", value );
queryHints.add( (QueryHint) AnnotationFactory.create( hintDescriptor ) ); queryHints.add( (QueryHint) AnnotationFactory.create( hintDescriptor ) );
} }
@ -1932,7 +1969,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
JPAOverridenAnnotationReader.class JPAOverridenAnnotationReader.class
); );
} }
catch (ClassNotFoundException e) { catch ( ClassNotFoundException e ) {
throw new AnnotationException( "Unable to find entity-class: " + clazzName, e ); throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
} }
ann.setValue( "resultClass", clazz ); ann.setValue( "resultClass", clazz );
@ -2130,7 +2167,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
this.getClass() this.getClass()
); );
} }
catch (ClassNotFoundException e) { catch ( ClassNotFoundException e ) {
throw new AnnotationException( "Unable to find id-class: " + attr.getValue(), e ); throw new AnnotationException( "Unable to find id-class: " + attr.getValue(), e );
} }
ad.setValue( "value", clazz ); ad.setValue( "value", clazz );
@ -2150,9 +2187,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
/** /**
* @param mergeWithAnnotations Whether to use Java annotations for this * @param mergeWithAnnotations Whether to use Java annotations for this
* element, if present and not disabled by the XMLContext defaults. * element, if present and not disabled by the XMLContext defaults.
* In some contexts (such as an association mapping) merging with * In some contexts (such as an association mapping) merging with
* annotations is never allowed. * annotations is never allowed.
*/ */
private PrimaryKeyJoinColumns getPrimaryKeyJoinColumns(Element element, XMLContext.Default defaults, boolean mergeWithAnnotations) { private PrimaryKeyJoinColumns getPrimaryKeyJoinColumns(Element element, XMLContext.Default defaults, boolean mergeWithAnnotations) {
PrimaryKeyJoinColumn[] columns = buildPrimaryKeyJoinColumns( element ); PrimaryKeyJoinColumn[] columns = buildPrimaryKeyJoinColumns( element );
@ -2189,7 +2226,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
if ( defaults.canUseJavaAnnotations() if ( defaults.canUseJavaAnnotations()
&& StringHelper.isEmpty( (String) entity.valueOf( "name" ) ) ) { && StringHelper.isEmpty( (String) entity.valueOf( "name" ) ) ) {
Entity javaAnn = getJavaAnnotation( Entity.class ); Entity javaAnn = getJavaAnnotation( Entity.class );
if ( javaAnn != null ) entity.setValue( "name", javaAnn.name() ); if ( javaAnn != null ) {
entity.setValue( "name", javaAnn.name() );
}
} }
return AnnotationFactory.create( entity ); return AnnotationFactory.create( entity );
} }
@ -2286,7 +2325,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
new ArrayList<Element>() : new ArrayList<Element>() :
(List<Element>) tree.elements( "secondary-table" ); (List<Element>) tree.elements( "secondary-table" );
List<SecondaryTable> secondaryTables = new ArrayList<SecondaryTable>( 3 ); List<SecondaryTable> secondaryTables = new ArrayList<SecondaryTable>( 3 );
for (Element element : elements) { for ( Element element : elements ) {
AnnotationDescriptor annotation = new AnnotationDescriptor( SecondaryTable.class ); AnnotationDescriptor annotation = new AnnotationDescriptor( SecondaryTable.class );
copyStringAttribute( annotation, element, "name", false ); copyStringAttribute( annotation, element, "name", false );
copyStringAttribute( annotation, element, "catalog", false ); copyStringAttribute( annotation, element, "catalog", false );
@ -2312,7 +2351,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
overridesDefaultInSecondaryTable( secTableAnn, defaults, secondaryTables ); overridesDefaultInSecondaryTable( secTableAnn, defaults, secondaryTables );
SecondaryTables secTablesAnn = getJavaAnnotation( SecondaryTables.class ); SecondaryTables secTablesAnn = getJavaAnnotation( SecondaryTables.class );
if ( secTablesAnn != null ) { if ( secTablesAnn != null ) {
for (SecondaryTable table : secTablesAnn.value()) { for ( SecondaryTable table : secTablesAnn.value() ) {
overridesDefaultInSecondaryTable( table, defaults, secondaryTables ); overridesDefaultInSecondaryTable( table, defaults, secondaryTables );
} }
} }
@ -2380,7 +2419,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
private PrimaryKeyJoinColumn[] buildPrimaryKeyJoinColumns(Element element) { 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" ); List pkJoinColumnElementList = element.elements( "primary-key-join-column" );
PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[pkJoinColumnElementList.size()]; PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[pkJoinColumnElementList.size()];
int index = 0; int index = 0;
@ -2407,7 +2448,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
else { else {
if ( mandatory ) { if ( mandatory ) {
throw new AnnotationException( throw new AnnotationException(
element.getName() + "." + attributeName + " is mandatory in XML overring. " + SCHEMA_VALIDATION element.getName() + "." + attributeName + " is mandatory in XML overriding. " + SCHEMA_VALIDATION
); );
} }
} }
@ -2422,7 +2463,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
int length = Integer.parseInt( attribute ); int length = Integer.parseInt( attribute );
annotation.setValue( annotationAttributeName, length ); annotation.setValue( annotationAttributeName, length );
} }
catch (NumberFormatException e) { catch ( NumberFormatException e ) {
throw new AnnotationException( throw new AnnotationException(
element.getPath() + attributeName + " not parseable: " + attribute + " (" + SCHEMA_VALIDATION + ")" element.getPath() + attributeName + " not parseable: " + attribute + " (" + SCHEMA_VALIDATION + ")"
); );

View File

@ -1,7 +1,7 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by * Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express * third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All * copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc. * third-party contributions are distributed under license by Red Hat Inc.
@ -86,8 +86,10 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
assertAnnotationPresent( ElementCollection.class ); assertAnnotationPresent( ElementCollection.class );
assertAnnotationPresent( OrderBy.class ); assertAnnotationPresent( OrderBy.class );
assertAnnotationNotPresent( OrderColumn.class ); assertAnnotationNotPresent( OrderColumn.class );
assertEquals( "col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class ) assertEquals(
.value() ); "col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class )
.value()
);
} }
public void testOrderColumnNoAttributes() throws Exception { public void testOrderColumnNoAttributes() throws Exception {
@ -152,8 +154,10 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
assertAnnotationNotPresent( MapKeyColumn.class ); assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class ); assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class ); assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertEquals( Entity2.class, reader.getAnnotation( MapKeyClass.class ) assertEquals(
.value() ); Entity2.class, reader.getAnnotation( MapKeyClass.class )
.value()
);
} }
public void testMapKeyTemporal() throws Exception { public void testMapKeyTemporal() throws Exception {
@ -166,8 +170,11 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
assertAnnotationNotPresent( MapKeyColumn.class ); assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class ); assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class ); assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertEquals( TemporalType.DATE, reader.getAnnotation( assertEquals(
MapKeyTemporal.class ).value() ); TemporalType.DATE, reader.getAnnotation(
MapKeyTemporal.class
).value()
);
} }
public void testMapKeyEnumerated() throws Exception { public void testMapKeyEnumerated() throws Exception {
@ -180,8 +187,11 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
assertAnnotationNotPresent( MapKeyColumn.class ); assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class ); assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class ); assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertEquals( EnumType.STRING, reader.getAnnotation( assertEquals(
MapKeyEnumerated.class ).value() ); EnumType.STRING, reader.getAnnotation(
MapKeyEnumerated.class
).value()
);
} }
/** /**
@ -387,8 +397,11 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
assertAnnotationPresent( Temporal.class ); assertAnnotationPresent( Temporal.class );
assertAnnotationNotPresent( Enumerated.class ); assertAnnotationNotPresent( Enumerated.class );
assertAnnotationNotPresent( Lob.class ); assertAnnotationNotPresent( Lob.class );
assertEquals( TemporalType.DATE, reader.getAnnotation( assertEquals(
Temporal.class ).value() ); TemporalType.DATE, reader.getAnnotation(
Temporal.class
).value()
);
} }
public void testEnumerated() throws Exception { public void testEnumerated() throws Exception {
@ -397,8 +410,11 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
assertAnnotationNotPresent( Temporal.class ); assertAnnotationNotPresent( Temporal.class );
assertAnnotationPresent( Enumerated.class ); assertAnnotationPresent( Enumerated.class );
assertAnnotationNotPresent( Lob.class ); assertAnnotationNotPresent( Lob.class );
assertEquals( EnumType.STRING, reader.getAnnotation( assertEquals(
Enumerated.class ).value() ); EnumType.STRING, reader.getAnnotation(
Enumerated.class
).value()
);
} }
public void testLob() throws Exception { public void testLob() throws Exception {
@ -666,8 +682,10 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
ElementCollection relAnno = reader.getAnnotation( ElementCollection.class ); ElementCollection relAnno = reader.getAnnotation( ElementCollection.class );
assertEquals( FetchType.EAGER, relAnno.fetch() ); assertEquals( FetchType.EAGER, relAnno.fetch() );
assertEquals( Entity3.class, relAnno.targetClass() ); assertEquals( Entity3.class, relAnno.targetClass() );
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class ) assertEquals(
.value() ); AccessType.PROPERTY, reader.getAnnotation( Access.class )
.value()
);
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by * Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express * third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All * copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc. * third-party contributions are distributed under license by Red Hat Inc.
@ -75,8 +75,10 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
assertAnnotationPresent( ManyToMany.class ); assertAnnotationPresent( ManyToMany.class );
assertAnnotationPresent( OrderBy.class ); assertAnnotationPresent( OrderBy.class );
assertAnnotationNotPresent( OrderColumn.class ); assertAnnotationNotPresent( OrderColumn.class );
assertEquals( "col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class ) assertEquals(
.value() ); "col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class )
.value()
);
} }
public void testOrderColumnNoAttributes() throws Exception { public void testOrderColumnNoAttributes() throws Exception {
@ -141,8 +143,10 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
assertAnnotationNotPresent( MapKeyColumn.class ); assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class ); assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class ); assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertEquals( Entity2.class, reader.getAnnotation( MapKeyClass.class ) assertEquals(
.value() ); Entity2.class, reader.getAnnotation( MapKeyClass.class )
.value()
);
} }
public void testMapKeyTemporal() throws Exception { public void testMapKeyTemporal() throws Exception {
@ -155,8 +159,11 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
assertAnnotationNotPresent( MapKeyColumn.class ); assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class ); assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class ); assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertEquals( TemporalType.DATE, reader.getAnnotation( assertEquals(
MapKeyTemporal.class ).value() ); TemporalType.DATE, reader.getAnnotation(
MapKeyTemporal.class
).value()
);
} }
public void testMapKeyEnumerated() throws Exception { public void testMapKeyEnumerated() throws Exception {
@ -169,8 +176,11 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
assertAnnotationNotPresent( MapKeyColumn.class ); assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class ); assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class ); assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertEquals( EnumType.STRING, reader.getAnnotation( assertEquals(
MapKeyEnumerated.class ).value() ); EnumType.STRING, reader.getAnnotation(
MapKeyEnumerated.class
).value()
);
} }
/** /**
@ -471,8 +481,10 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
assertEquals( FetchType.EAGER, relAnno.fetch() ); assertEquals( FetchType.EAGER, relAnno.fetch() );
assertEquals( "field2", relAnno.mappedBy() ); assertEquals( "field2", relAnno.mappedBy() );
assertEquals( Entity3.class, relAnno.targetEntity() ); assertEquals( Entity3.class, relAnno.targetEntity() );
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class ) assertEquals(
.value() ); AccessType.PROPERTY, reader.getAnnotation( Access.class )
.value()
);
} }
} }

View File

@ -193,8 +193,10 @@ public class Ejb3XmlManyToOneTest extends Ejb3XmlTestCase {
assertFalse( relAnno.optional() ); assertFalse( relAnno.optional() );
assertEquals( Entity3.class, relAnno.targetEntity() ); assertEquals( Entity3.class, relAnno.targetEntity() );
assertEquals( "col1", reader.getAnnotation( MapsId.class ).value() ); assertEquals( "col1", reader.getAnnotation( MapsId.class ).value() );
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class ) assertEquals(
.value() ); AccessType.PROPERTY, reader.getAnnotation( Access.class )
.value()
);
} }
public void testCascadeAll() throws Exception { public void testCascadeAll() throws Exception {

View File

@ -1,7 +1,7 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by * Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express * third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All * copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc. * third-party contributions are distributed under license by Red Hat Inc.
@ -78,8 +78,10 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
assertAnnotationPresent( OneToMany.class ); assertAnnotationPresent( OneToMany.class );
assertAnnotationPresent( OrderBy.class ); assertAnnotationPresent( OrderBy.class );
assertAnnotationNotPresent( OrderColumn.class ); assertAnnotationNotPresent( OrderColumn.class );
assertEquals( "col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class ) assertEquals(
.value() ); "col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class )
.value()
);
} }
public void testOrderColumnNoAttributes() throws Exception { public void testOrderColumnNoAttributes() throws Exception {
@ -144,8 +146,10 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
assertAnnotationNotPresent( MapKeyColumn.class ); assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class ); assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class ); assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertEquals( Entity2.class, reader.getAnnotation( MapKeyClass.class ) assertEquals(
.value() ); Entity2.class, reader.getAnnotation( MapKeyClass.class )
.value()
);
} }
public void testMapKeyTemporal() throws Exception { public void testMapKeyTemporal() throws Exception {
@ -158,8 +162,11 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
assertAnnotationNotPresent( MapKeyColumn.class ); assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class ); assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class ); assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertEquals( TemporalType.DATE, reader.getAnnotation( assertEquals(
MapKeyTemporal.class ).value() ); TemporalType.DATE, reader.getAnnotation(
MapKeyTemporal.class
).value()
);
} }
public void testMapKeyEnumerated() throws Exception { public void testMapKeyEnumerated() throws Exception {
@ -172,8 +179,11 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
assertAnnotationNotPresent( MapKeyColumn.class ); assertAnnotationNotPresent( MapKeyColumn.class );
assertAnnotationNotPresent( MapKeyJoinColumns.class ); assertAnnotationNotPresent( MapKeyJoinColumns.class );
assertAnnotationNotPresent( MapKeyJoinColumn.class ); assertAnnotationNotPresent( MapKeyJoinColumn.class );
assertEquals( EnumType.STRING, reader.getAnnotation( assertEquals(
MapKeyEnumerated.class ).value() ); EnumType.STRING, reader.getAnnotation(
MapKeyEnumerated.class
).value()
);
} }
/** /**
@ -522,8 +532,10 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
assertEquals( "field2", relAnno.mappedBy() ); assertEquals( "field2", relAnno.mappedBy() );
assertTrue( relAnno.orphanRemoval() ); assertTrue( relAnno.orphanRemoval() );
assertEquals( Entity3.class, relAnno.targetEntity() ); assertEquals( Entity3.class, relAnno.targetEntity() );
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class ) assertEquals(
.value() ); AccessType.PROPERTY, reader.getAnnotation( Access.class )
.value()
);
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by * Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express * third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All * copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc. * third-party contributions are distributed under license by Red Hat Inc.
@ -288,10 +288,14 @@ public class Ejb3XmlOneToOneTest extends Ejb3XmlTestCase {
assertFalse( relAnno.optional() ); assertFalse( relAnno.optional() );
assertTrue( relAnno.orphanRemoval() ); assertTrue( relAnno.orphanRemoval() );
assertEquals( Entity3.class, relAnno.targetEntity() ); assertEquals( Entity3.class, relAnno.targetEntity() );
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class ) assertEquals(
.value() ); AccessType.PROPERTY, reader.getAnnotation( Access.class )
assertEquals( "field3", reader.getAnnotation( MapsId.class ) .value()
.value() ); );
assertEquals(
"field3", reader.getAnnotation( MapsId.class )
.value()
);
} }
} }

View File

@ -30,10 +30,9 @@ import java.lang.reflect.AnnotatedElement;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import org.hibernate.Hibernate;
import org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader; import org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader;
import org.hibernate.cfg.annotations.reflection.XMLContext; import org.hibernate.cfg.annotations.reflection.XMLContext;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.testing.junit.functional.annotations.HibernateTestCase; import org.hibernate.testing.junit.functional.annotations.HibernateTestCase;
/** /**
@ -64,14 +63,23 @@ abstract class Ejb3XmlTestCase extends HibernateTestCase {
//Do nothing //Do nothing
} }
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[0];
}
protected void assertAnnotationPresent(Class<? extends Annotation> annotationType) { protected void assertAnnotationPresent(Class<? extends Annotation> annotationType) {
assertTrue( "Expected annotation " + annotationType.getSimpleName() + " was not present", assertTrue(
reader.isAnnotationPresent( annotationType ) ); "Expected annotation " + annotationType.getSimpleName() + " was not present",
reader.isAnnotationPresent( annotationType )
);
} }
protected void assertAnnotationNotPresent(Class<? extends Annotation> annotationType) { protected void assertAnnotationNotPresent(Class<? extends Annotation> annotationType) {
assertFalse( "Unexpected annotation " + annotationType.getSimpleName() + " was present", assertFalse(
reader.isAnnotationPresent( annotationType ) ); "Unexpected annotation " + annotationType.getSimpleName() + " was present",
reader.isAnnotationPresent( annotationType )
);
} }
protected JPAOverridenAnnotationReader getReader(Class<?> entityClass, String fieldName, String ormResourceName) protected JPAOverridenAnnotationReader getReader(Class<?> entityClass, String fieldName, String ormResourceName)
@ -98,9 +106,4 @@ abstract class Ejb3XmlTestCase extends HibernateTestCase {
xmlContext.addDocument( doc ); xmlContext.addDocument( doc );
return xmlContext; return xmlContext;
} }
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[0];
}
} }

View File

@ -1,7 +1,7 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by * Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express * third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All * copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc. * third-party contributions are distributed under license by Red Hat Inc.

View File

@ -1,7 +1,7 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by * Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @author tags or express * third-party contributors as indicated by either @author tags or express
* copyright attribution statements applied by the authors. All * copyright attribution statements applied by the authors. All
* third-party contributions are distributed under license by Red Hat Inc. * third-party contributions are distributed under license by Red Hat Inc.

View File

@ -1,39 +1,39 @@
//$Id$ //$Id$
package org.hibernate.test.annotations.xml.ejb3; package org.hibernate.test.annotations.xml.ejb3;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.OneToMany; import javax.persistence.NamedQuery;
import javax.persistence.NamedQuery; import javax.persistence.OneToMany;
import javax.persistence.TableGenerator; import javax.persistence.TableGenerator;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@Entity @Entity
@NamedQuery(name="manufacturer.findAll", query = "from Manufacturer where 1 = 2") @NamedQuery(name = "manufacturer.findAll", query = "from Manufacturer where 1 = 2")
@TableGenerator(name="generator", table = "this is a broken name with select from and other SQL keywords") @TableGenerator(name = "generator", table = "this is a broken name with select from and other SQL keywords")
public class Manufacturer { public class Manufacturer {
private Integer id; private Integer id;
private Set<Model> models = new HashSet<Model>(); private Set<Model> models = new HashSet<Model>();
@Id @Id
public Integer getId() { public Integer getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
@OneToMany @OneToMany
public Set<Model> getModels() { public Set<Model> getModels() {
return models; return models;
} }
public void setModels(Set<Model> models) { public void setModels(Set<Model> models) {
this.models = models; this.models = models;
} }
} }