Hibernate version: 3.1
Hibernate Annotations version: 3.1beta8
Annotations are generating an association table with two columns each with foreign keys. That is all correct
The problem is that both columns should also be primary keys - they are not. The table gets no primary key at all.
The following has worked previously with mapping normal generic collections. The only difference in this situation is that the class is using the <C extends Version>. This makes the generic collections type unknown at compile time, which appears to be the issue.
This is the BassClass which contains the property which should be mapped as the primary key
Code:
@MappedSuperclass
public abstract class BaseClass
{
private Long id;
@Id @GeneratedValue(strategy=GenerationType.AUTO )
public final Long getId()
{
return id;
}
...
}
This is the base version class that is on the other side of the one to many relationship.
Code:
@Entity
Class Version extends BaseClass
{
...
}
This is the class with the mapping information.
Code:
@Entity
public class History<C extends Version> extends BaseClass
{
private List<C> versions;
...
@OneToMany( targetEntity=Version.class )
public List<C> getVersions()
{
return versions;
}
...
}
Is there something wrong with this mapping (shouldnt be)
This maybe a small bug in the annotations that prevents it from finding the key when the type is not well defined using generics.
If it isnt a bug what am I doing wrong - If it is, is there a work around.