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 a RESTful web service from an existing database


To create a RESTful web service from an existing database, we simply need to go to File | New in a web application project, then select the Web Services category, and select the RESTful Web Services From Database file type:

In the next step in the wizard, we need to pick a data source and select one or more tables to use to generate our web service. In our example, we will generate a web service for the CUSTOMER table of the sample database included in NetBeans.

Now, we need to enter a package for our web service code.

Then, we need to pick a Resource Package or simply accept the default value of service. It is a good idea to enter a package name that follows standard package naming conventions.

When we click on Finish, our RESTful web service code is generated.

Analyzing the generated code

The wizard discussed in the previous section creates a JPA entity for each chosen table, along with an AbstractFacade class and a Facade class for...