Lately I've been finding instances where the annotation configuration is ignoring annotated properties on my classes. For example:
Code:
public class SomeClass {
@Id
@Column(...)
private Long firstEntityId;
@Id
@Column(...)
private Long secondEntityId;
@ManyToOne
@PrimaryKeyJoinColumn(...)
private FirstEntity firstEntity;
@ManyToOne
@PrimaryKeyJoinColumn(...)
private SecondEntity secondEntity;
@Id
@Basic(...)
private Integer sequence;
}
1. Annotation configuration completely ignores the "sequence" property. If I try this,
Code:
public class FirstEntity {
@OneToMany
@OrderBy( "sequence" )
private List<SomeClass> blah = new LinkedList<SomeClass>();
}
then I get "property from @OrderBy clause not found: SomeClass.sequence".
2. It seems redundant to have two properties for a @ManyToOne mapping; one for the primary key part, the other for the actual entity. Is this necessary by design, or is there another way to map them? I've tried,
Code:
@Id @ManyToOne private FirstEntity firstEntity;
but again, it completely ignores this property and I get errors later on! This approach honestly seems more intuitive to me, but assuming I'm wrong, having annotations ignore the property and reporting general "property not found" errors later on is frustrating. Am I simply doing all this wrong, or, if I could find the time (!! :), would it be helpful for me to submit patches for additional error checking/validation to the hibernate-annotations code?