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

(cherry picked from commit 6a48cccd5d250fb25768fd9c7a28c750f002c6f9)
This commit is contained in:
Steve Ebersole 2012-09-05 12:34:03 -05:00
parent 0c271ac77a
commit 053b676684

View File

@ -1399,13 +1399,14 @@ private static int addProperty(
* 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 ) ) { }
else if ( prop.isAnnotationPresent( JoinColumns.class ) ) {
for ( JoinColumn columnAnnotation : groupAnnotation.value() ) { for ( JoinColumn columnAnnotation : groupAnnotation.value() ) {
if ( columnName.equals(columnAnnotation.name() ) ) { if ( columnName.equals( columnAnnotation.name() ) ) {
isRequiredAnnotationPresent = true; isRequiredAnnotationPresent = true;
break; break;
} }
@ -1414,12 +1415,19 @@ private static int addProperty(
if ( isRequiredAnnotationPresent ) { if ( isRequiredAnnotationPresent ) {
//create a PropertyData fpr the specJ property holding the mapping //create a PropertyData fpr the specJ property holding the mapping
PropertyData specJPropertyData = new PropertyInferredData( PropertyData specJPropertyData = new PropertyInferredData(
declaringClass, //same dec declaringClass,
prop, // the actual @XToOne property //same dec
propertyAccessor, //TODO we should get the right accessor but the same as id would do prop,
// the actual @XToOne property
propertyAccessor,
//TODO we should get the right accessor but the same as id would do
mappings.getReflectionManager() mappings.getReflectionManager()
); );
mappings.addPropertyAnnotatedWithMapsIdSpecj( entity, specJPropertyData, element.toString() ); mappings.addPropertyAnnotatedWithMapsIdSpecj(
entity,
specJPropertyData,
element.toString()
);
} }
} }
} }