Java Data Object is an API (Application program interface) ,used by java programing language to interact with the database. It is very effective with both relational and object oriented databases. JDO allows the programmer to access the database using java instead of using specific database languages such as SQL. JDO allows the programmer to persist java objects.
The JDO is not an alternative to JDBC ,programmer can make use of each of its capabilities . JDBC offer direct control over underlying database thorough queries while JDO offers better convenience to programmer offering database independent way to handle the datasource.
Advantages of JDO
Portability
Application developed using JDO will run in any implementation of JDO with out any need of recompiling, since it is the meta data describe the behavior of JDO instead of java source code
Ease of use
JDO allows the programmer to concentrate on their document object mode without being worried about object persistence ,which is handled by JDO itself.
Database portability
The JDO application is independent on underlying database. So JDO will work with different database from different vendors.
Performance
JDO can optimize the database access, results improved performance in database operations without any burden to the programmer.
Performance
JDO can be integrated with EJB. This feature allows the programmer to use both these API together.
Container agnostic
Since JDO is very lightweight it doesn't need any particular container . So the JDO applications can be implemented like normal desktop (jsp,servlet etc) application.
JDO Programming Model
JDO Programming Model has the following aspects
PersistenceManager
The PersistenceManager handles the access,transactions and queries about underlying data source. It acts as interface between the application and the data source.
Transaction
Transaction defines a atomic unit of work for data management,which satisfies ACID properties.
Query
The JDO query language known as JDOQL is used to query the persistent object with the given criteria. This language is independent of query language of underlying data source, which makes it suitable for any type of database .
PersistenceCapable classes
The JDO query language known as JDOQL is used to query the persistent object with the given criteria. This language is independent of query language of underlying data source, which makes it suitable for any type of database .
Persistence-aware classes
These classes process persistance-capable classes.
Normal classes
These are normal classes used in the application
Working
The JDO has three phases
1.Design -creating an ordinary class
public class me
{
String myname;
public String getMyname() { return myname; }
public void setMyname(String myname) { this.myname = myname; }
}
2.Preparation -make the ordinary class persistent using JDO enhancer.
Create a package.jdo file for writing meta data information for the class. This file is placed with class file.
<'xml version="1.0" encoding="UTF-8"'>
<!DOCTYPE jdo SYSTEM "jdo.dtd">
<jdo>
<package name="pack.pack">
<class name="me" identity-type="application" objectidclass="EmployeeKey">
<field name="name" primary-key="true">
</field>
</class>
</package>
</jdo>
To get PersistenceManager from PersistenceManagerFactory with given implementation
Properties proper = new Properties();
proper.put(...);//give implementation
// get a PersistenceManagerFactory
PersistenceManagerFactory pmft = JDOHelper.getPersistenceManagerFactory(proper);
PersistenceManager pm = pmf.getPersistenceManager();
Set ManagedConnectionFactoryImpl to PersistenceManager
persist me by pm.makePersistent(new me("me"));
3. Run time - implements persistence
JDO offer interface definition to manipulate stored data and convert them to native objects. It is easy to learn, use and implement, providing a standard for object persistence. There are many open source implementation available for JDO.
The JDO is not an alternative to JDBC ,programmer can make use of each of its capabilities . JDBC offer direct control over underlying database thorough queries while JDO offers better convenience to programmer offering database independent way to handle the datasource.
Advantages of JDO
Portability
Application developed using JDO will run in any implementation of JDO with out any need of recompiling, since it is the meta data describe the behavior of JDO instead of java source code
Ease of use
JDO allows the programmer to concentrate on their document object mode without being worried about object persistence ,which is handled by JDO itself.
Database portability
The JDO application is independent on underlying database. So JDO will work with different database from different vendors.
Performance
JDO can optimize the database access, results improved performance in database operations without any burden to the programmer.
Performance
JDO can be integrated with EJB. This feature allows the programmer to use both these API together.
Container agnostic
Since JDO is very lightweight it doesn't need any particular container . So the JDO applications can be implemented like normal desktop (jsp,servlet etc) application.
JDO Programming Model
JDO Programming Model has the following aspects
PersistenceManager
The PersistenceManager handles the access,transactions and queries about underlying data source. It acts as interface between the application and the data source.
Transaction
Transaction defines a atomic unit of work for data management,which satisfies ACID properties.
Query
The JDO query language known as JDOQL is used to query the persistent object with the given criteria. This language is independent of query language of underlying data source, which makes it suitable for any type of database .
PersistenceCapable classes
The JDO query language known as JDOQL is used to query the persistent object with the given criteria. This language is independent of query language of underlying data source, which makes it suitable for any type of database .
Persistence-aware classes
These classes process persistance-capable classes.
Normal classes
These are normal classes used in the application
Working
The JDO has three phases
1.Design -creating an ordinary class
public class me
{
String myname;
public String getMyname() { return myname; }
public void setMyname(String myname) { this.myname = myname; }
}
2.Preparation -make the ordinary class persistent using JDO enhancer.
Create a package.jdo file for writing meta data information for the class. This file is placed with class file.
<'xml version="1.0" encoding="UTF-8"'>
<!DOCTYPE jdo SYSTEM "jdo.dtd">
<jdo>
<package name="pack.pack">
<class name="me" identity-type="application" objectidclass="EmployeeKey">
<field name="name" primary-key="true">
</field>
</class>
</package>
</jdo>
To get PersistenceManager from PersistenceManagerFactory with given implementation
Properties proper = new Properties();
proper.put(...);//give implementation
// get a PersistenceManagerFactory
PersistenceManagerFactory pmft = JDOHelper.getPersistenceManagerFactory(proper);
PersistenceManager pm = pmf.getPersistenceManager();
Set ManagedConnectionFactoryImpl to PersistenceManager
persist me by pm.makePersistent(new me("me));
3. Run time " implements persistence
JDO offer interface definition to manipulate stored data and convert them to native objects. It is easy to learn, use and implement, providing a standard for object persistence. There are many open source implementation available for JDO.