EmbeddedId « Map « JPA Q&A





1. Which anotation should I use: @IdClass or @EmbeddedId    stackoverflow.com

The JPA (Java Persistence API) specification has 2 different ways to specify entity composite keys: @IdClass and @EmbeddedId. I'm using both annotations on my mapped entities, but it turns out to ...

2. JPA Compound key with @EmbeddedId    stackoverflow.com

In a legacy database, I have three tables: Users, Workgroups, and UsersWorkgroup. UsersWorkgroup stores what role a user has in a workgroup. Here are the relevant code snippets:

@Entity
@Table(name = "users_workgroup")
public class UsersWorkgroup ...

3. Difference using @Id and @EmbeddedId for a compound key    stackoverflow.com

I've created an entity that uses @Id to point to an @Embeddable compound key. Everything I believe works fine as is. However, after switching @Id to @EmbeddedId everything continues ...

4. Hibernate: @EmbeddedId, Inheritance and @SecondaryTable    stackoverflow.com

I'm using Hibernate version 3.3.2.GA with annotations. I have inheritance between two classes, the former:

@Entity
@Table(name = "SUPER_CLASS")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
    name="DISCR_TYPE",
    discriminatorType= DiscriminatorType.STRING
)
@org.hibernate.annotations.Entity(mutable = false)
public class SuperClass ...

5. How to set a backreference from an @EmbeddedId in JPA    stackoverflow.com

Does someone know if it is possible to establish a backreference from within a JPA @EmbeddedId. So for example there is an Entity of the Form

@Entity
public class Entity1 {
   ...

6. JPA 2 "Not an managed type" error with @EmbeddedId field    stackoverflow.com

I have the following class with an @EmbeddedId.


package aop.web.tech.rmodels;

// Generated Jan 7, 2011 12:47:02 PM by Hibernate Tools 3.2.2.GA

import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 ...

7. OpenJPA cascade persist one-to-many with @EmbeddedId    stackoverflow.com

I have the following entities: Invoice

@Entity
@Table(name = "invoice")
public class Invoice implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "InvoiceID")
private Long invoiceID;
@Basic(optional = false)
@Column(name = "Date")
@Temporal(TemporalType.DATE)
private Date date;
@OneToMany(cascade = ...

8. @onetoone and @EmbeddedId    stackoverflow.com

I am trying to create a one-to-one relation between a class, lets call it First, and another one lets call it second. It wont allow me to do so if the class ...

9. Hibernate exception with @MapsId, @EmbeddedId    stackoverflow.com

I've got a problem with @MapsId annotation and @EmbeddedId. When running a code in Hibernate I get:

Caused by: org.hibernate.PropertyAccessException: could not set a field value by reflection setter ...





10. Seam x JPA x @EmbeddedId    seamframework.org

Hello! I have lots of many-to-many ralationships in a already created database! Ive created the entities using JPA through Eclipse. Thus, for the EmbeddedIds, from my many-to-many relationships, I have a separated entity created by JPA (something like xxxxxPK)! Then, I tried to use seam generate selecting the "already have entities" through Eclipse. Seam identified correctly all EmbeddedIds but wrote xxxxxxxId ...

11. @EmbeddedID - JPA    java.net

@GeneratedValue was working fine, the issue was that there were two mappings to the CD_PRODUTO field: the ManyToOne mapping and the @Id mapping (cdProduto attribute in the ItemProdutoPK.class). The ManyToOne mapping was set to read-only (insertable=false, updateable=false), and so even though this reference was set, the field was still being entered as null because the cdProduto attribute was left as null ...

12. @EmbeddedId that contains an Identity column on SQL Server    forum.hibernate.org

This Oct 2009 thread included the suggestion that a workaround would involve a UserType implementation. I implemented UserType to deal with enumerations back in Hibernate 2 days, but it is not clear to me how a UserType would help implement a composite PK especially one that includes a sequence column. Can anyone provide an overview of how that would work?

13. @EmbeddedId and null field    forum.hibernate.org

Hi everybody, I'm using Hibernate 3.3.2 with Oracle 10g. I have a table A without primary key defined (don't tell me why, legacy system...). A has 14 fields, so hb2ddl tool created two Classes: A and AId, where the latter is the set of all the table's fields. Among these fields, only 3 have the not null constraint. The problem is: ...

14. Audited class with @EmbeddedId and @ManyToOne relationship    forum.hibernate.org

Newbie Joined: Fri Nov 28, 2008 5:11 pm Posts: 2 Hi, i have a problem when I try to make a class @Audited when this class have an @EmbeddedId (only when the Embeddable class have ManyToOne relationship). Code: persistence.xml: Code: org.hibernate.ejb.HibernatePersistence ...

15. IllegalArgumentException w/ Criteria, @EmbeddedId, FetchMode    forum.hibernate.org

Author Message alecbritton Post subject: IllegalArgumentException w/ Criteria, @EmbeddedId, FetchMode Posted: Thu Jun 30, 2011 5:01 pm Newbie Joined: Mon Oct 11, 2010 5:24 pm Posts: 6 I am having a strange issue when using Criteria queries and FetchMode with an @EmbeddedId entity. The entity in question has a PK field from the embedded ID class also mapped as ...

16. @EmbeddedId, @MapsId and HHH-5764 in Hibernate JIRA    forum.hibernate.org

Hi, I have 7 entities/tables RatePlan/RATE_PLAN, PlanedSvc/PLANED_SVC, PlanedZone/PLANED_ZONE, PlanedDay/PLANED_DAY, Svc/SVC, Zone/ZONE, Day/DAY. Svc/SVC, Zone/ZONE and Day/DAY are irrelevant to this topic and code not listed. RatePlan has bi-directional one-to-many relationship to PlanedSvc PlanedSvc's derived identifier = RatePlan.id + Svc.svcId PlanedSvc has bi-directional one-to-many relationship to PlanedZone PlanedZone's derived identifier = PlanedSvc.id + Zone.id PlanedZone has bi-directional one-to-many relationship to PlanedDay PlanedDay's ...





17. @OneToOne and @EmbeddedId    forum.hibernate.org

Is it not possible to use one-to-one mappings if the object being mapped (the target) uses a composite class as a primary key? I am trying to create a one-to-one relation between a class, lets call it First, and another one lets call it second. It wont allow me to do so if the class Second uses a @EmbeddedId as its ...

19. @Embeddedid with one field being auto_increment    forum.hibernate.org

Hello, I have a table with Integer + String composite key integer being the auto_increment field. MYSQL supports this kind of primary key so it generates the integer field. But I cannot get it read back into the entity after and insert. I tried various types of annotations with @IdClass and @EmbeddedId... I also tried to implement an interceptor and implemented ...

20. cache problem with @EmbeddedId/@AttributeOverrides    forum.hibernate.org

Author Message timecop Post subject: cache problem with @EmbeddedId/@AttributeOverrides Posted: Fri Nov 10, 2006 2:53 pm Newbie Joined: Fri Nov 10, 2006 2:06 pm Posts: 2 Problem description Following process gets a org.hibernate.cache.CacheException after hotdeploy/redeploy: - start JBoss AS and deploying my ear-file - get some information stored in db (ejb3 entity) using the web interface Here's everything fine. ...

21. JPA @IdClass/@EmbeddedId in subclasses?    forum.hibernate.org

In our data model, we have a set of three tables: Code: - Foo_Values o PK Column: FOO_ID o PK Column: VERSION_ID o PK Column: LANGUAGE_CODE - Foo_Ref o PK ...