- I use a class Set and a separate class IndexedSet.
- Set has an association implemented by SetAssignment.
- IndexedSet has an association implemented by IndexedSetAssignment, which is a child class of SetAssignment
- Both SetAssignment and IndexedSetAssignment use @EmbeddedIDs implemented by the classes SetAssignmentId and IndexedSetAssignmentId (the latter as a child of the first).
- The examples, of course, show only fragments of the real structure :-)
The following error arises on "mvn hibernate3:hbm2ddl":
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: IndexedSetAssignment.set in IndexedSet.assignmentsI do not understand why:
IndexedSet.assignments referenced to IndexedSetAssignment.set, although "set" is inherited by its father class SetAssignment. Why does hibernate not use the propertiy of its father class?
Can you help me?
Code:
@Entity
class Set implements Serializable {
@OneToMany(mappedBy="set")
@MapKey
Map<SetAssignmentId, SetAssignment> setassignments;
(...)
}
@Entity
class IndexedSet implements Serializable {
@OneToMany(mappedBy="set")
@OrderBy("index")
List<IndexedSetAssignment> setassignments;
(...)
}
@Entity
class SetAssignment implements Serializable {
@EmbeddedId
private SetAssignmentId id;
@ManyToOne
@JoinColumn(name="set", insertable = false, updatable = false, nullable = false)
private Set set;
(...)
}
@Embeddable
class SetAssignmentId implements Serializable {
private Long set;
(...)
}
@Entity
class IndexedSetAssignment extends SetAssignment implements Serializable {
@Column(name="index", insertable=false, updatable=false, nullable=true)
private int index;
(...)
}
@Embeddable
class IndexedSetAssignmentId extends SetAssignmentId implements Serializable {
private Integer index;
(...)
}