Skip to main content


Showing posts from July, 2007

Java Persistance

Recently I explored a bit how one can easily make use of the new Java Persistance API. The example below shows how one can very quickly create and search records from a Derby database table called "Course".

To keep things simple and at the same time examine exactly the code required for such a task I created a simple console application from my netbeans 5.5.1 IDE. The new persistance API is much lighter than the previous version and was taken out from the Enterprise API thus making it possible to use it from simple java applications. Once I created my console app I added a new "Entity class from Database" to the project. A dialog is displayed and the connection chosen must be previously defined from the Runtime->Databases section in Netbeans. In the dialog I as well chose the option to "Create Persistance Unit" using the Toplink Library and named it "PUnit".

Once one goes through these simple steps automatically Netbeans creates an Entity class…