Note: This ORM/SQL annotation is silently ignored by ObjectDB
288 words
javax.persistence.MapsId - JPA annotation
javax.persistence
Annotation MapsId
- Target:
- Fields (including property get methods)
Designates a
ManyToOne or
OneToOne relationship attribute that provides the
mapping for an EmbeddedId primary key, an attribute within
an EmbeddedId primary key, or a simple primary key of
the parent entity. The value element specifies the
attribute within a composite key to which the relationship
attribute corresponds. If the entity's primary key is of the same
Java type as the primary key of the entity referenced by the
relationship, the value attribute is not specified.
Example:
// parent entity has simple primary key @Entity public class Employee { @Id long empId; String name; ... } // dependent entity uses EmbeddedId for composite key @Embeddable public class DependentId { String name; long empid; // corresponds to primary key type of Employee } @Entity public class Dependent { @EmbeddedId DependentId id; ... @MapsId("empid") // maps the empid attribute of embedded id @ManyToOne Employee emp; }
- Since:
- JPA 2.0
String value
(Optional) The name of the attribute within the composite key
to which the relationship attribute corresponds. If not
supplied, the relationship maps the entity’s primary
key.
- Default value:
- ""
- Since:
- JPA 2.0
This documentation page is derived (with some adjustments) from the open source JPA 2 RI (EclipseLink)
and is available under the terms of the Eclipse Public License, v. 1.0 and Eclipse Distribution License, v. 1.0.
and is available under the terms of the Eclipse Public License, v. 1.0 and Eclipse Distribution License, v. 1.0.
Object Relational Mapping (ORM) JPA 2 providers include Hibernate, EclipseLink, TopLink, OpenJPA and DataNucleus.
Object DB is not an ORM JPA implementation but an Object Database for Java with built in JPA 2 support.