Java Reference
In-Depth Information
After clicking Next> , we need to select the appropriate datasource. In this example
we will use the datasource we created in Chapter 5. After selecting the appropriate
datasource ( jdbc/customerdb in our case), verifying the connection information and
entering the password, we need to select the tables we will be generating JPA entities
for. Although we will be working primarily with one table, it doesn't hurt to generate
entities for all tables.
At this point we have all the JPA entities for our project. The generated JPA entities
by default do not use a primary key generation strategy. In order to have primary
keys generated automatically, we need to decorate the getter method for the
primary key field in our entities with the @GeneratedValue annotation; the default
generation strategy is AUTO . If we need to override the generation strategy then
we can use one of the generation strategies discussed in Chapter 5 Interacting with
Databases through the Java Persistence API .
 
Search WWH ::




Custom Search