Java Reference
In-Depth Information
Checking the
Use Column Names in Relationships
checkbox results in fields for
one-to-many and one-to-one to be named after the column name in the database
table the generated entity maps to. This field is checked by default. However, in
our experience, unchecking it results in more readable code.
Checking the
Use Defaults if Possible
checkbox results in NetBeans only generating
annotations that override the default behavior.
Checking the
Generate Fields for Unresolved Relationships
checkbox results in
NetBeans generating fields whose entities cannot be resolved.
After clicking on
Finish
, NetBeans generates JPA entities for all tables in
the database.
Our database contains a table named
CUSTOMER
. Let's take a look at the generated
Customer
JPA entity:
package com.ensode.jpa;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;