Reputation: 22803
I apologize if this is an obvious question, but I'm going through the Java EE 6 tutorial while reading a couple books and it's getting hard to correlate all of the information.
I'm doing a little comparison between JDO and JPA. I understand that with JPA and an application server, I can quite easily say something like:
@Stateless
public class MyEJB {
@PersistenceContext
private EntityManager em;
// methods that use the JPA entity manager...
}
Then, within my own methods, I can use em
to get at a JPA EntityManager. Whatever methods I write will (by default) automatically create or join up with an existing transaction.
I'd like to have this much fun with JDO. I suspect the right answer is to use CDI. I'm not sure what that would look like though, perhaps this?
@Stateless
public class MyEJB {
@Resource
private PersistenceManager em;
// methods that use the JDO persistence manager...
}
But this guesswork leaves me with more questions than answers.
Apart from imposing a dependency on JDO and probably DataNucleus directly I'd rather keep this as Java EE 6 as possible, without involving Spring or other third party libraries, but I'd take a third party library over nothing.
Thanks!
Upvotes: 2
Views: 937
Reputation: 15577
http://www.datanucleus.org/products/accessplatform_3_0/jdo/j2ee.html covers many aspects of Java EE, and gives examples for several Java EE servers including JBoss 7 (the latest spec). It is a contributory effort since nobody uses all such servers; if you have details to add then post them on the DataNucleus forum and they can be included
Upvotes: 1