JDO Presentation given at Java User Group Switzerland (JUGS) on 31.03.05
1. Java Data Objects (JDO) Overview and Future Michael Vorburger, Vertical*i Java User Group Switzerland Zurich, 31.03.05
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
Hinweis der Redaktion
Many applications deal with “data”. It is very natural for both OOP developers as well as for other stakeholders such as subject matter experts to think in terms of objects for that data, a Domain Model, the class “Customer” with a String name and the Collection of associated Order instances etc. But objects “die” when you “pull the plug” – they are in-memory constructs of our software. So the question that invariably comes up is: how do we “keep” those objects? More technically speaking, how and when should we store/save those objects somewhere, how do we find them again, how do we do this transactionally, how do we do all of this efficiently? Of course, we have all seen different approaches to this: Business objects with Save methods and dirty flags, persistence related code more or less intermixed with domain related code (AKA your in-house object persistence layer), or with no real domain model in the application code at all, and natively interfacing with the API of your datastore, only. Transparent, or orthogonal, Object Persistence is a concept in which an application and more importantly the domain model is independent of the underlying persistence infrastructure. Developers are able to work with objects marked once as persistent directly in their code, just like with any other application objects. Create your new Customer, call some persist() method – and you are done. Add a new Order object – it becomes “persistent by reachability”. While that may sound simplistic, conceptually object persistence really doesn’t have to be more complicated. Finding those persistent objects again doesn’t have to be complicated either – think OOP, think Java, navigate through the domain model data object graph: Get the Orders for a Customers by calling something like a getOrders() method on the Customer class, a real and simple plain old java object POJO, implemented simply as a return of some private orders collections. Of course, sometimes you don’t have a reference, e.g. somehow we have to find the Customer first – a chicken and egg problem. Instead of adding all instances [of a certain class] to a big allObjects Collection, which I mention because conceptually I think it’s interesting to think of it that way, all persistence frameworks offer some query language and API; some have a concept called root or named objects in addition. Then there are Transactions and Concurrency… certainly an entire topic on it’s own, but in the context of transparent object persistence, as long as the persistence layer has a way of being informed when we are about to start making changes that are to be considered a “unit” from a functional point of view, and when we are done making those changes (commit) or don’t actually want to make them (abort), then any real persistence layer ensure the ACID [Atomicity, Consistency, Isolation, Durability] transactional properties and handle concurrency issues with one of the known locking approaches etc. Many concerns can conceptually be considered “internal” to a truly transparent persistence layer. For example, while we have spoken about the domain model object graph, and how relationships can be traversed etc, I didn’t mean to imply that the entire graph be physically in memory… indeed all real and scalable persistence frameworks of course provide partial read or updates, loading-as-needed, caches, expirations, etc. But those are essentially “under the hood” and internal issues that you generally should have no interest in from the model and the using application’s point of view. One last note before moving on to the next slide: We haven’t spoken about relational databases so far – I prefer the term “datastore” concerning what we have spoken up here. A datastore can be, and certainly very often is, a relational database. An object database is another form of datastore, agreed historically not very popular, but still something to keep in mind. So is an LDAP directory. A modern content repository is also a datastore..
JDO does not require e.g. member variables to be public or package local, or user-written implementation of certain interfaces or superclass extension. Nor does it prevent the same – public member variables can work – if entire code is byte code enhanced.
Single-String JDOQL Form: Complete String form, not necessarily String + API calls; e.g. for sorting, and new features Projections: Result is no longer necessarily subset of candidate collection, but could just a few attributes (SQL select like) Aggregates: Allows min, max, avg, sum, count. Group By and Having. More String expressions More numeric, Map functions Paging query results Native SQL User-defined Result Class
JDO 2.0 JSR first rejected, I'd say because of "political reasons"
Data Transfer Objects, Value Objects
Serializable for Remote DTO – JDO will never Serialize
Implicit detachment also if the instance or an instance containing a reference to the instance is serialized; or the persistence manager managing the instance is closed and the new DetachOnClose property is true.
Outside J2EE container, how to access & use not yet clear, apparently. I asked the question to the EJB Spec Lead at the Server Side Conference, and the response, if I understood it correctly, was something to the effect of ... or Hibernate, or TopLink - more or less ignoring the fact that a JCP approved javax.* API for persistence already existed. Last year, a window of opportunity - It hasn't happened - Point it: That discussion is probably history now.
Also Persistence Metadata – separate. JDO2 and EJB3 detachment behavior is also in alignment: This means that semantic behavior of domain model is thesame in both EJB3 and JDO2
Oracle apparently already has implementation? Now 2-3y is a LONG time out in this industry... ;-) Personally, I think JDO is going to stick around longer than some people think, but in the end will be replaced by “EJB” 3.x persistence… which will have nothing much to do with “EJB” as we know and think of it today. Interesting what this will mean for the “container” as we know it today… think BEA WebLogic, IBM WebSphere. I’d say they’ll possibly pick up JDO vendors – maybe not. JDO vendors tell everybody who is willing to listen loud and clear. Tough sale, but not unheard of (e.g. a Versant ODB implementation for "1000 times faster" WebSphere EJB 2.1 Entity Beans)