EmbeddedId « Composite « JPA Q&A

1. JPA/Hibernate: What's better for composite primary keys, @IdClass or @EmbeddedId implementations and why?    stackoverflow.com

what's better for JPA/Hibernate composite primary keys, @IdClass or @EmbeddedId implementations and why? This is an intentionally naive question. I decided to use @EmbeddedId (for whatever reason) and I feel like I ...

2. JPA - Criteria API and EmbeddedId    stackoverflow.com

I want to use criteria to make the following query. I have an Entity with EmbeddedId defined:

 public class Interfase implements Serializable {

  private InterfaseId id;

3. JPA (Hibernate, EclipseLink) mapping: why doesn't this code work (chain of 2 relationships using JPA 2.0, @EmbeddedId composite PK-FK)?    stackoverflow.com

I have three tables:

CREATE TABLE PostAddresses
  contact_id INTEGER NOT NULL,
  ordinal_nbr SMALLINT NOT NULL,
  PRIMARY KEY (contact_id, ordinal_nbr)

  contact_id INTEGER NOT NULL,
  ordinal_nbr SMALLINT ...

4. How to create a composite primary key which contains a @ManyToOne attribute as an @EmbeddedId in JPA?    stackoverflow.com

I'm asking and answering my own question, but i'm not assuming i have the best answer. If you have a better one, please post it! Related questions:

5. Mapping a class that consists only of a composite PK without @IdClass or @EmbeddedId    stackoverflow.com

I've got two tables A and B with simple PK's.

public class A { 
    public int idA;

public class B { 

6. Readonly on @Column in embeddedID composite key classes bug?    forum.hibernate.org

@Entity @Table(name = "Zips") public class Zip implements Serializable { @EmbeddedId private ZipId embeddedId; @ManyToOne ...