Java Reference
In-Depth Information
After deploying and executing our project in NetBeans, we should see the following
output in the output console of GlassFish:
We can see the output of the generated myTimer() method in the GlassFish log.
This method is being invoked automatically every 30 seconds (as specified in
the @Schedule annotation) by the EJB Timer service.
Generating session beans from
JPA entities
One very nice NetBeans feature is that it allows the generation of stateless session
beans from the existing JPA entities. The generated session beans act as Data Access
Objects ( DAOs ). This feature, combined with the ability to generate JPA entities
from an existing database schema, allows us to completely generate the data access
layers of our application without having to write a single line of Java code.
To take advantage of this functionality, we need to create an EJB project (go to File |
New Project , select Enterprise from the Categories list, select EJB Module from the
Projects list), or use the EJB project from an Enterprise Application project and add
some JPA entities to it either by manually coding them or by generating them from
an existing schema as discussed in Chapter 4 , Interacting with Databases through the
Java Persistence API .
Once we have some JPA entities in the project, we need to go to File | New File ,
select Persistence from the categories list, and select Session Beans For Entity
Classes from the File Types list.
 
Search WWH ::




Custom Search