EJB 3.0 Persistence

The second session i attended today at Javapolis was a session by Mike Keith of Oracle. Mike is a co-spec lead for the EJB 3.0 specification, and he has a lot of persistence experience. He also works on Oracle’s Toplink project.

I shortly talked to Mike before his presentation, and asked the question most people using Oracle’s ORM frameworks ask. What’s it going to be, ADF Business Components or Toplink? This is an interesting question, especially now that Toplink is part of the EJB 3.0 Reference Implementation. What is Oracle using for its own projects? According to Mike both ADF-BC and Toplink are being used for new projects, but most projects seem to prefer Toplink. He expects most people to move to EJB 3 once it’s released and stable.

Mike started his presenation with a slide called “About You”, which i liked. It showed that he really had thought about who his audience was, and what they wanted to get out of the presenation. It’s a bit surprising, but too many presenters forget to do this. Maybe it would be a good idea to send all presenters a copy of “Beyond Bullet Points”. Knowing your audience is one of the main points of this book. (Another one is to get rid of all the bullet pointed text on your slides. I think this works really well, even for technical presentations. Just show code and diagrams.)

Anyway, back to the subject, EJB 3.0 persistence. A new reference implementation will available by New Year 2006, and the final release is expected for JavaOne 2006. The reference implementation uses Suns Application server, Glassfish, and Oracle ORM framework, Toplink essentials. Toplink essentials is a stripped down version of Toplink, without some extras like the Oracle DB specific extensions, object xml mapping, etc.

Mike explained the goals of EJB 3, simplicity, what an entity is, how to use annotations and xml, to define mapping and ids. Also discussed where the Persistence Context, Entity Manager, Entity lifecycle. The entity manager API contains methods to persist, refresh, remove and query objects. Using callbacks you can add business logic before and after updates, inserts, and deletes. Again, these callbacks can be specified using annotations. He finished the session with some examples of queries, named queries, native queries and relationship mapping.

I liked Mike’s presention, he gave a good introduction into EJB 3.0. I also think EJB 3 has a good change of becoming the standard ORM framework (not just on paper), since you can also use it in JSE application without a JEE container. It’s also a lot simpler that previous EJB versions.