JPA Objects requires that all entities have
an @Id
property (or inherit one from a
superclass). If this isn't the case then JPA Objects' metamodel
validator will throw an exception, and the application won't
boot.
JPA Objects currently does
not support composite primary keys. Specifically,
the @IdClass
annotation (which specifies a
composite primary key class mapped to multiple properties of the entity)
is not allowed. The @EmbeddedId
annotation (which
is applied to a persistent property of an entity class or mapped
superclass to denote a composite primary key that is an embeddable
class) is also not allowed.
This restriction is by design. Coupled with discriminators, JPA Objects can guarantee that every entity instance can be identified in a standard fashion. See Section 2.5, “Specify a discriminator” for further discussion.
In addition, the @Id
property should be a
wrapper class, eg java.lang.Integer
rather than
int
. This allows the JPA
provider (Hibernate) to distinguish between transient and persisted
objects if no @Version
property has been
specified; transient objects have a null
id.