Classes to be generated

The following picture and the table underneath provide you with information about the types of files that can be generated (mainly Java classes) and the relations between them. Types that are shown in green are not generated but help visulaizing the relationships.

You can click on the the types in the picture to get to the related entry in the table.

main

Target JavaDoc
EntityClass This is the main type of file to be generated. A generated “EntityClass” will hold data and
is annotated with JPA annotations. Optionally, Java Bean Validation annotations are
getting added, too.
EntityDAO A generated “EntityDAO” class contains logic to use an entity manager
instance for CRUD operations. An entity DAO also is the place where you
should implement custom queries. Having them in a central place fosters
re-use of query functionality and leads to a better organized codebase.
EntityDAOUnitTest A generated “EntityDAOUnitTest” holds the testing logic for the corresponding
generated “EntityDAO” class. The generated source file includes logic to
initialize an entity manager factory and to get an instance of an entity manager.
To accomplish this, the persistence units that are generated in the persistence.xml
are being used.
EntityLifecycleListener An “EntityLifecycleListener” class is a class that provides mostly empty implementations
for the JPA listener methods for @PrePersist, @PostPersist, @PostLoad, @PreUpdate, @PostUpdate,
EntityUnitTest A generated “EntityUnitTest” has generated setUp and tearDown methods to get
an entity manager instance that is needed for testing the handling of entities.
The unit test class has implemented methods for FIND, PERSIST, MERGE and REMOVE functionality.
OrmXml The generated “OrmXml” file amongst others provides the option to set a default schema name
to be used by all entities that are listed in the persistence.xml from where the orm.xml
file is being referenced.
PersistenceXml The generated “PersistenceXml” file lists all the entity classes and includes
two persistence units. One unit for the transaction type “JTA” and one for the
transaction type “RESOURCE_LOCAL”. “RESOURCE_LOCAL” is going to be used to
execute unit tests outside of the application container. If you plan to use
the entities outside of an application server, you can use this unit to handle persistent
data in your JSE application.
TestDataGenerator A generated “TestDataGenerator” holds an implementation that is capable
of creating and inserting test data into a database by using pure Java
code instead of using SQL-statements. This test data is meant to be used
for tests during development and should not be added to production databases.
TestDataGeneratorUnitTest A generated “TestDataGeneratorUnitTest” is meant to be used to execute the
data-creation logic in the “TestDataGenerator” class.
ThreadLocalSessionData The purpose of a generated “ThreadLocalSessionData” class is to store user-related data in a thread-local in order
to make this data easily available within classes where there cannot be any objects
injected by means of @Inject or @EJB. An example of this are JPA entity lifecycle listeners
where there is no injection functionality available.
Note that starting with JPA 2.1, CDI injection is supported for lifecycle listeners.

 

JPA 2.0

The generated Java code uses annotations of JPA 2.0. There is no dependency to a specific JPA provider. In addition to the JPA annotations, annotations of Java Bean Validation are used.

Database Schema

The generator presumes that there is no existing database schema. The database schema will be getting created based on the annotated entity classes, by means of functionality that is supplied by a JPA provider.

Persistence Units

The persistence.xml contains two persistence units. One with the transaction type RESOURCE_LOCAL and one with the transaction type JTA. For both units the same set of class name is listed in the persistence.xml. The unit with RESOURCE_LOCAL includes properties for a JPA provider. To use the unit with JTA you need make some configurations in the application server.