Hibernate version: Annotations 3.3.0 GA
Database:Oracle 10g
I'm trying to map an inheritance hierarchy where the parent entity has a composite primary key, but I get an exception saying the child entity has the wrong number of columns.
Primary Key Class:
Code:
@Embeddable
public class TaskPK implements Serializable
{
private String name;
@ManyToOne
private TaskType type;
...
}
Parent Class:
Code:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Task
{
@EmbeddedId
private TaskPK key;
...
}
Child Class:
Code:
@Entity
@PrimaryKeyJoinColumns({
@PrimaryKeyJoinColumn(name = "name"),
@PrimaryKeyJoinColumn(name = "type_name")})
public class Squall extends Task
{
private String location;
...
}
ManyToOne class in TaskPK:
Code:
@Entity
public class TaskType
{
@Id
private String name;
private String className;
...
}
When I deploy this setup I get the following exception:
Quote:
org.hibernate.AnnotationException: A Foreign key refering test.entity.Task from test.entity.Squall has the wrong number of column. should be 1
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:255)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:580)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1211)
It looks like it's saying the PK is only 1 column, but it's really 2.
Any idea what the issue is?