HHH-7568 - Add JPA1.0 compound key compatability when orm descriptor file used to override annotations.

(cherry picked from commit 6a48cccd5d)
This commit is contained in:
Steve Ebersole 2012-09-05 12:34:03 -05:00
parent 0c271ac77a
commit 053b676684
1 changed files with 35 additions and 27 deletions

View File

@ -1394,33 +1394,41 @@ public final class AnnotationBinder {
String columnName = element.getAnnotation( Column.class ).name(); String columnName = element.getAnnotation( Column.class ).name();
for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) { for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
if ( !prop.isAnnotationPresent( MapsId.class ) ) { if ( !prop.isAnnotationPresent( MapsId.class ) ) {
/** /**
* The detection of a configured individual JoinColumn differs between Annotation * The detection of a configured individual JoinColumn differs between Annotation
* and XML configuration processing. * and XML configuration processing.
*/ */
boolean isRequiredAnnotationPresent = false; boolean isRequiredAnnotationPresent = false;
JoinColumns groupAnnotation = prop.getAnnotation(JoinColumns.class); JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class );
if ( ( prop.isAnnotationPresent( JoinColumn.class ) if ( (prop.isAnnotationPresent( JoinColumn.class )
&& prop.getAnnotation( JoinColumn.class ).name().equals( columnName ) ) ) { && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) {
isRequiredAnnotationPresent = true; isRequiredAnnotationPresent = true;
} else if ( prop.isAnnotationPresent( JoinColumns.class ) ) { }
for ( JoinColumn columnAnnotation : groupAnnotation.value() ) { else if ( prop.isAnnotationPresent( JoinColumns.class ) ) {
if ( columnName.equals(columnAnnotation.name() ) ) { for ( JoinColumn columnAnnotation : groupAnnotation.value() ) {
isRequiredAnnotationPresent = true; if ( columnName.equals( columnAnnotation.name() ) ) {
break; isRequiredAnnotationPresent = true;
} break;
} }
} }
if ( isRequiredAnnotationPresent ) { }
//create a PropertyData fpr the specJ property holding the mapping if ( isRequiredAnnotationPresent ) {
PropertyData specJPropertyData = new PropertyInferredData( //create a PropertyData fpr the specJ property holding the mapping
declaringClass, //same dec PropertyData specJPropertyData = new PropertyInferredData(
prop, // the actual @XToOne property declaringClass,
propertyAccessor, //TODO we should get the right accessor but the same as id would do //same dec
mappings.getReflectionManager() prop,
); // the actual @XToOne property
mappings.addPropertyAnnotatedWithMapsIdSpecj( entity, specJPropertyData, element.toString() ); propertyAccessor,
} //TODO we should get the right accessor but the same as id would do
mappings.getReflectionManager()
);
mappings.addPropertyAnnotatedWithMapsIdSpecj(
entity,
specJPropertyData,
element.toString()
);
}
} }
} }
} }