Hi,
I'm using Hibernate 3.6.1.Final with Spring 3.0.5.RELEASE via org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean. I'm not able to override the join table name for a one-to-many association using AssociationOverride.joinTable when my entity extends a mapped superclass where this association is declared.
I'm trying to do something like this:
Code:
@MappedSuperclass
public abstract class TreeItem<T extends TreeItem<T>> {
@OneToMany(fetch = FetchType.LAZY)
@JoinTable (
name = "parent_child",
joinColumns = @JoinColumn(name = "parent_id"),
inverseJoinColumns = @JoinColumn(name = "child_id"))
private Collection<T> children= new HashSet<T>();
}
@Entity
@Table(name = "purpose")
@AssociationOverride(name = "children",
joinTable = @JoinTable(name = "purpose_children",
joinColumns = @JoinColumn(name = "parent_id"),
inverseJoinColumns = @JoinColumn(name = "child_id")))
public class PurposeCode extends TreeItem<PurposeCode>{
@Id
private Long id;
}
But hibernate generates only the
parent_child table and not the
purpose_children one as I suppose.
I have several other entities to extend TreeItem and everyone from them has its own separate join table.
I've googled around the net and also search in JIRA but I didn't find any notice this should not work. What am I doing wrong?