Customizing Roo-generated identifier definition
So far we have seen recipes where the JPA entity identifier is generated by Spring Roo. By default, entities created by Roo specify the identifier generation strategy as GENERATIONTYPE.AUTO
, which means that the persistence provider will choose an appropriate strategy for the database. You may want to customize this identifier generation strategy based on your application's requirements.
In this recipe, we'll look at how we can modify a Roo-generated identifier definition to use a database table for generating identifier values.
Getting ready
Exit the Roo shell and delete the contents of the C:\roo-cookbook\ch03
-recipes directory.
Start the Roo shell from the C:\roo-cookbook\ch03
-recipes directory.
Execute the ch03_jpa_setup.roo
script which creates the flight-app
Roo project, sets up Hibernate as a persistence provider, and configures MySQL as the database for the application. If you are using a different database than MySQL or your connection...