Compound « Key « JPA Q&A





1. Compound keys in JPA    stackoverflow.com

I want to make an entity that has an autogenerated primary key, but also a unique compound key made up of two other fields. How do I do this in JPA?
I ...

2. Joining tables with Compound Keys in JPA/Hibernate    stackoverflow.com

Okay, our DB team has come up with the following structure. I cannot change it: Report

  • has Reference Number (REF_NR) as its PID
  • plus some data about the report, report date and so ...

3. JPA: how to model compound key which contains also a foreign key?    coderanch.com

Hi developers, I would like to have some piece of advice by you gurus about a modelling problem I am currently experiencing in my (simplified) JPA scenario I have: Building entity (identified by an id) Room entity (identified by number, floor and building) Of course both Room and Building have other info fields. A coleague of mine proposed to - create ...

4. Compound Primary Keys    forum.hibernate.org

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 ...

5. Compound Key with two parent tables help    forum.hibernate.org

(parent) CREATE TABLE doctors ( id numeric(10) NOT NULL, name varchar(30), CONSTRAINT doctors_pk PRIMARY KEY (id) ) (parent) CREATE TABLE patients ( id numeric(10) NOT NULL, name varchar(30), CONSTRAINT patients_pk PRIMARY KEY (id) ) (children) CREATE TABLE addresses ( id numeric(10) NOT NULL, <-- either the doctors.id ...

6. Error when updating a compound key    forum.hibernate.org

Newbie Joined: Mon May 19, 2008 2:30 am Posts: 2 Hibernate version: 3.2.5 Database name and version: PostgreSQL, version: 8.3.0 Hi there, I've been dealing with this for several hours and I would really appreciate any help that you could provide me. I've 2 entities, one called "Empleados" (Employees) and another one called "Ausencias" (Absences). I have created their respective entities ...

7. Compound key from other childobject    forum.hibernate.org

Hibernate version: 2.2 I am having trouble with a fairly complex relationship I am trying to create. I want to have a child object which has a compound key, but part of that key comes from a field on another child object. In this case the JeanieUserTyped.ApplicationId = ShortCode.ApplicationId Below is the invalid mapping file (applicationId is wrong) Mapping documents:

8. JPA One-To-Many with Compound Key    forum.hibernate.org

Author Message bdrhoa Post subject: JPA One-To-Many with Compound Key Posted: Tue Jun 16, 2009 4:06 am Newbie Joined: Tue Jun 16, 2009 3:39 am Posts: 3 Hi, I have 3 tables: MetadataCollection, Item and CollectionItem. The primary key for CollectionItem is the composit key collection_id+item_id. So CollectionItem item has an @Embeddable CollectionItemPK class. My question is how do ...