How to use Java Persistence API with netbeans rich client applications.

Hi guys,
I think you might be interested in this:

I worked on a project just last week and chose to use the netbeans platform and JPA.
This was my final workaround and some points to note:
I first created a java class library (from the netbeans java templates), just a normal java class library. I then added a persistence unit, just right clicking and choosing add >> persistence unit.
I created my entity classes and in a different package, created a class that exposed methods for adding,updating and deleting information using the entitymanager.

In my netbeans module that sought to do database related stuff, I created a library wrapper class for the java class library just created and created a dependency on it.
From there I could then have access to the class that exposed the methods for adding, updating and deleting. It seems to me each netbeans module uses its own class loader, cos from here if you run the application, there is a class definition error or something implying the persistence classes cannot be found. Take heart, follow on…

My workaround
Go to tools >> libraries and look for Toplink Essentials. Check the classpath and notice the paths to all the jar files there. Create a new netbeans library wrapper project and include all the jar files there. Create a depency on this library wrapper project for any netbeans module that dares to call the class using the persistence. By this, a definition of the persistence is available to pacify anything that requests a definition of it.

Advertisements

One thought on “How to use Java Persistence API with netbeans rich client applications.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s