The first thing to decide when implementing your persistence layer is which classes are to be persisted. If you need to persist a field/property then you must mark that class as persistable. In JPA there are three types of persistable classes.
Let's take a sample class (Hotel) as an example We can define a class as persistable using either annotations in the class, or XML metadata.
To achieve the above aim with XML metadata, we do this
<entity class="org.datanucleus.test.Hotel"> ... </entity>
Alternatively, using JPA Annotations, like this
@Entity public class Hotel { ... }
In the above example we have marked the class as an entity. We could equally have marked it as mapped-superclass (using annotation @MappedSuperclass, or XML element <mapped-superclass>) or as embeddable (using annotation @Embeddable, or XML element <embeddable>).
See also :-
With JPA you cannot access public fields of classes. DataNucleus allows an extension to permit this, but such classes need special enhancement. To allow this you need to
You perform the annotation of the class as follows
@PersistenceAware public class MyClassThatAccessesPublicFields { ... }
See also :-