I am a medical doctor who is interested in IT related to medicine. I studied at Mahinda College, Galle, Sri Lanka and Royal College, Colombo 7, Sri Lanka. I got my MBBS in 2002 from Faculty of Medicine, Karapitiya, Galle and worked as a Medical Officer for 6 years. Now I am reading for MSc(Biomedical Informatics) at Postgraduate Institute of Medicine, Colombo 7. I have developed several medical applications like electronic medical records, laboratory management software and pharmacy management software. Now my main interest is Bioinformatics and its applications like personalized medicine, finding drug targets, gene therapy and preventive medicine. Buddhika has posted 2 posts at DZone. View Full User Profile

Object Database Programming with JPA and NetBeans

12.28.2010
| 46932 views |
  • submit to reddit

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


-->
Legacy
Article Resources: 
Published at DZone with permission of its author, Buddhika Ariyaratne.

(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

Well done Mr. Buddhika, this is a great effort. You have done a very good article, which explains everything clearly. Even though I have not worked with ObjectDB, this seems really interesting. I have used derby database (much similar to this) sometime back, for a data synchronization with the main database. The main advantages of this type of databases are, they are very lightweight, and the access time is minimal as they are running on same machine. Anyway you cannot used them for large scale distributed systems, but works perfectly with small desktop applications.

Shehan Simen M P replied on Mon, 2011/01/03 - 4:54am

Hi Buddhika, this is a very good article for someone who is starting OODBMS. I have not used ObjectDB so my understanding about it is limited.
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

Very good tutorial !

Instant Tax Sol... replied on Thu, 2011/08/04 - 10:51am

Thеу аrе completely іn line wіth modern oppose oriented languages lіkе Java. Although relational databases dominate today, thеrе іѕ a very high chance οf shifting thе market balance іn favour οf Oppose databases іn future. -Instant Tax Solutions

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.