-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Using Inheritance where parent entity has composite PK
PostPosted: Mon Jun 04, 2007 1:03 pm 
Newbie

Joined: Mon Jun 04, 2007 12:16 pm
Posts: 1
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.