Java Reference
In-Depth Information
The default entities generated from the tables do not contain the complete code for
the entities. We need to add named queries for finding entities by ID and finding
all entities.
Edition entity
First, we modify the entity. Add named queries to find all
Edition entities and find an Edition entity by ID:
@NamedQueries( { @NamedQuery(name = "findEditionsAll",
query = "select o from Edition o"),
@NamedQuery(name = "findEditionById",
query = "SELECT o from Edition o
WHERE = :id")} )
The Edition entity implements the Serializable interface. An entity bean that is
persisted by an entity manager uses caches to serialize the entity bean. Add a static
final variable to associate the entity versions with a version number:
static final long serialVersionUID = 1;
As the Edition entity bean has a one-to-many relationship with the Section and
Article entities, add parameterized variables of type List for the Section and
Article entities:
private List<Section> sections;
private List<Article> articles;
Search WWH ::

Custom Search