Object Database Programming with JPA and NetBeans
I have been developing Java applications for a long time and the major difficulty was the coding part related to database manipulations. Recently I shifted to use Object-Relational Mapping through JPA. I have used TopLink, EclipseLink, and Hibernate. I could achieve the functionally I want with ease without worrying on the database development. I have also used some Object databases like neoDatis directly which need no object relational mapping. Finally I found the ObjectDB, an Object database for Java which supports JPA.
This article demonstrates how to create a simple JAVA Standard application in NetBeans using ObjectDB and JPA. The demonstrated application uses JPA to store and retrieve objects of two entity classes from an Embedded ObjectDB. It will demonstrate the capabilities of ObjectDB and JPA, which include persisting objects, removing saved objects and retrieving persisted objects. For this tutorial, besides the Java JDK and the NetBeans IDE, you only need to download and extract the ObjectDB distribution zip file. The distribution zip contains everything necessary without any external dependency.
This tutorial consists of the following steps:
- Step 1: Create an ObjectDB Enabled Java SE Project
- Step 2: Define a JPA Entity Classes
- Step 3: Add a Main Class
- Step 4: Design a Graphical User Interface
- Step 5: Code user-defined Methods
- Step 6: Code Events of Controls
- Step 7: Run the program
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)





Comments
Andrew McVeigh replied on Wed, 2010/12/29 - 5:35am
i've used ObjectDB for a few years now, including in a commercial product, and it is very, very good. Very fast too and it can handle enormously complex schemas if required.
A further plus point is that it is relatively small (around 1mb).
Anura Pushpakumara replied on Thu, 2010/12/30 - 12:10pm
Regarding an article posted by Mr. Buddhika there are more than one database management systems exist. But reason is all have some advantageous as well as disadvantageous over each other. Actually Object Oriented Databases are well work with some applications. But those can't be suggested for better for another applications. As a example Object Oriented types are well suitable for applications like Computer Aided Software Engineering, Computer Aided Manufacturing and Computer Aided Designing, Multimedia applications. However it depends on applications sombody is going to be developed. This will be required to design with architecture intended to be applied. Advantageous of OODBMS are reduce paging, capable of develop an application with less coding, easier navigation (accessing speed is low), data models are really mapped to real world objects, good for distributed architecture. But there are some disadvantageous comparatively with RDBMS. Efficeiency is less when handle with simple data and with simple relationship. relational tables are simpler, access speed is lower due to late binding, less user tools support for OODBMS, standards for OODBMS are not more stable. Anyway as a conclusion what can I state is the selection of DBMS depends on which type of application will going to be developed.
Jagath replied on Thu, 2010/12/30 - 11:00pm
Shehan Simen M P replied on Mon, 2011/01/03 - 4:54am
Still RDBMS are the most popular in the enterprise applications due to several reasons. I have used several DBs which performs well when the size and schema is simple and extremely slow when it grows. So it is hard to conclude by developing a simple application. I think it is more important to think about the performance, extensibility and maintainability of the system rather than focusing on the easiness of the development. The end user would not care whether it is a OODBMS or a RDBMS as long as it serves the purpose. So it is better to do a good analysis of the advantages of OODBMS over RDBMS. Right now, Oracle,MySql combined with JPA/Hibernate is dominating the market and it might take sometime for OODBMS to get into the market.
I have skimmed through the code and I believe that you could have used Java5 Generics for some cases without doing type casting. Well done!
Drabo Constantin replied on Thu, 2011/01/06 - 4:46am
Instant Tax Sol... replied on Thu, 2011/08/04 - 10:51am