Thankfully all of the steps described in the previous paragraph are automated
when using NetBeans with the bundled GlassFish application server. When using
this combination, all we need to do is open our Enterprise Application Project then
right-click on it and select Debug , at this point the application server is started in
debug mode (or restarted in debug mode if it was already running in standard
mode), the application is deployed and the debugger is automatically attached to
the application server.
We will use a simple application involving JSF, CDI, and JPA to illustrate NetBeans
When persisting data in JPA entities, we either need to set the primary key explicitly
when inserting a new row in the database, or we need to set automatic primary
key generation using the @GeneratedValue annotation. In our example we will use
neither approach, this will make our application break when inserting new rows.
Here is the relevant code for the JPA entity: