JDO vs Value Object
JDO is a Java persistence technology that can be used to store POJO (Plain Old Java Objects) in to databases without the need to understand the underlying implementations of different data stores. Value Object (also known as Data Transfer Object) is an abstract design pattern which introduces the concept of a simple data holder for the purpose of transferring data between multiple layers and tiers.
What is JDO?
JDO (Java Data Objects) provides a mechanism to deliver persistence to Java objects and database access. JDO is highly transparent because it allows the Java applications developers to access the underlying data without having to write any code specific to databases. JDO can be used across several tiers including Java Standard Edition, Web-tier and application servers. JDO API is an alternative to other persistence (keeping objects after the abortion of the program) of Java objects such as Serialization, JDBC (Java DataBase Connectivity) and EJB CMP (Enterprise JavaBeans architecture Container Managed Persistence). JDO uses XML and enhancement of bytecode. The main advantage of using JDO API is that they can store data without the need of learning a new query language such as SQL (which depends upon the type of data storage). JDO is very easy to use since developers can focus only on their domain object model. Not only this, JDO optimizes code by itself according to data access. Because JDO API is not strict on the type of the data store, same interface can be used by the java application developers to store java objects to any data store including relational database, object database or a XML. JDO is highly portable because modification or recompilation is not needed to run on different vendor implementations.
What is Value Object?
Value Object also known as Data transfer Objects (DTO) is a simple abstract design pattern that deals with a data container to hold data for the purpose of transferring data between layers and tiers. Although the most accurate term for this pattern is the Data Transfer Object, due to a mistake in Core J2EE’s first version it was introduced as Value Object. Although this mistake was corrected in the 2nd edition, this name became popular and is still used heavily instead of Data Transfer Object (but it should be noted that the correct term is Data Transfer Object). DTO design pattern is used with entity beans, JDBC and JDO to rectify problems occurring with regard to isolation and transactions in enterprise applications. It is important to note that these are only simple data holders used to transfer data between the client and the database and they do not provide persistence of any sort. DTO serves the purpose of acting as Serializable objects in traditional EJB (as entity beans before 3.0 are not serializable). In a separate assembly phase defined by DTO, all data used by the view are acquired and marshaled before the release of the control to the presentation layer.
What is the difference between JDO and Value Object?
JDO is actually a persistence technology used to store Java objects in to databases which provides convenience to the developers by handling all the implementation level details and allowing the developers to focus on non database-specific coding. But, the Value Object represents an abstract design pattern (not a technology) that provides a generic data holder known as a Data Transfer Object which can hold data for the purpose of transferring between client and databases. JDO provides the facility of persisting data items, while Value Object only deals with keeping data temporarily during the period of data transfer. In other words, Value Object does not provide persistence.