Book Image

Java EE 7 Development with NetBeans 8

By : David R Heffelfinger
5 (1)
Book Image

Java EE 7 Development with NetBeans 8

5 (1)
By: David R Heffelfinger

Overview of this book

Table of Contents (18 chapters)
Java EE 7 Development with NetBeans 8
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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...