Chapter 2. JPA Objects / Naked Objects Restrictions

Table of Contents

2.1. Annotate with @Entity xor @Embeddable
2.2. Annotate properties, not fields
2.3. Specify a primary key using @Id (not using @IdClass or @EmbeddedId)
2.4. Specify a @GeneratedType for the Id
2.5. Specify a discriminator
2.6. No support for Enumerated Types
2.7. No support for Maps
2.8. No support for Named Native Query (@NamedNativeQuery)
2.9. No support to access underlying JPA Persistence Context

The intent of JPA Objects is to allow you to exploit the knowledge you (may already) have of JPA to set up persistence for a Naked Objects applications. As such, most of the annotations of JPA can be used "in the regular way". That said, JPA Objects does not support a number of annotations, either:

Those in the first category are enforced through validation provided by the metamodel (provided by an implementation of Naked Objects' org.nakedobjects.metamodel.specloader.validator.MetaModelValidator interface).

This chapter describes these restrictions.

2.1. Annotate with @Entity xor @Embeddable

Most domain classes will be annotated either as @Entity or, if an aggregated object, then as @Embeddable. The principle exceptions to this will be classes that factor out common properties (see Section 8.5, “Common Properties (@MappedSuperclass)”) and also value types (see Chapter 6, Supporting Custom Value Types).

It doesn't make sense for a domain class to be annotated using both @Entity and @Embeddable. JPA Objects' metamodel validator will therefore reject any domain model (that is, Naked Objects will fail to boot) where a domain class is annotated with both.

JPA Objects also ensures that at least one classes is loaded annotated with @Entity.