/*
* put element annotated by @Id in front
* since it has to be parsed before any association by Hibernate
*/
final XAnnotatedElement element = propertyAnnotatedElement.getProperty();
if ( element.isAnnotationPresent( Id.class ) || element.isAnnotationPresent( EmbeddedId.class ) ) {
annElts.add( 0, propertyAnnotatedElement );
/**
* The property must be put in hibernate.properties as it's a system wide property. Fixable?
* TODO support true/false/default on the property instead of present / not present
* TODO is @Column mandatory?
* TODO add method support
*/
if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
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()
);
}
}
}
}
}
if ( element.isAnnotationPresent( ManyToOne.class ) || element.isAnnotationPresent( OneToOne.class ) ) {
mappings.addToOneAndIdProperty( entity, propertyAnnotatedElement );
}
idPropertyCounter++;
}
else {
annElts.add( propertyAnnotatedElement );
}
if ( element.isAnnotationPresent( MapsId.class ) ) {
mappings.addPropertyAnnotatedWithMapsId( entity, propertyAnnotatedElement );
}
return idPropertyCounter;
}