Java Reference
In-Depth Information
Generating Session Beans from JPA
Entities
One very nice NetBeans feature is that it allows generation of stateless session beans
from existing JPA entities. The generated session beans act as DAO's (Data Access
Objects). 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 (
File
|
New
Project
, select
Enterprise
from the
Categories
list, then 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 5.
Once we have some JPA entities in the project, we need to go to
File
|
New
, select
Persistence
from the categories list, and
Session Beans For Entity Classes
from the
File Types
list.