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