-->
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: Compound Primary Keys
PostPosted: Mon May 03, 2010 4:39 pm 
Newbie

Joined: Wed Nov 18, 2009 7:00 pm
Posts: 12
I have a requirement to have a compound key for my database schema.

Below is my compound key:

@Embeddable
public class CompoundPK implements Serializable {

@Column(name="REGION_ID")
private long regionId;

private long id;

//omitted constructors, getters, setters for brevity.
}

My entity hierarchy is below
@Entity
@Table(name="table1")
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class NamedEntity{
@EmbeddedId
protected CompoundPK id;

@Column(name="LAST_NAME")
protected String lastName;

}

@Entity
@Table(name="table2")
public class Person extends NamedEntity{

@Column(name = "DATE_OF_BIRTH)
private Date dob;

....

}

However I'm unable to use the compound primary key. Is this a Hibernate limitation, where compound keys can't be used in Inheritance?

Thanks in advance


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.