inheritance « Composite « JPA Q&A

1. How do you implement inheritance with tables that have multi-column/composite primary keys (JPA 1.0 @IdClass)?

Given the following tables:

  first_name VARCHAR(50) NOT NULL,
  last_name VARCHAR(50) NOT NULL,
  birth_date DATE NOT NULL,
  PRIMARY KEY (first_name, last_name)

  first_name VARCHAR(50) ...

2. Composite Key in JPA / Hibernate with inherited class

i have a composite id defined on my class structure as below. Unfortunatly i always get a hibernate error that complains on the not found "part2": "Property of @IdClass not found in ...

3. Composite Foreign Key Issue while using Inheritance in JPA

I have a JPA Entity StatsEntity which has a composite primary key that is also as foreign key to another Entity Roster. This is setup as a @OneToOne relationship using @JoinColumns({@JoinColumn...}) ...

5. Inheritance and composite id mapping problem

@Entity @Inheritance(strategy=InheritanceType.JOINED) @Table(name="texts") public abstract class Text { @Id @Column(name="text_id", updatable=false, nullable=false) private long id; @OneToMany(orphanRemoval=true, cascade={CascadeType.ALL}, fetch=FetchType.LAZY) @JoinColumn(name="text_id") private List languageTexts = new ArrayList(); String description; protected Text(){} ... ...

6. Inheritance using composite primary keys

I want to create an inheritance structure by using annotations; the inheritance type is InheritanceType.JOINED. When using an integer as ID in the base entity everything works fine, but when using a composite ID the binding of the concrete entity fails. Does anyone why? The code looks like follows: [code]@Entity @Inheritance(strategy = InheritanceType.JOINED) public class Base implements Serializable { private BasePK ...

8. Inheritance + Composite Primary Keys

Code: @Entity public class Company implements Serializable { @Id private Long id; @Column(nullable = false, unique=true) private String name; public Company() { } getter .. setter... } @Embeddable public class Apk ...