Note that there are some explanatory texts on larger screens.

plurals
  1. POJDO with Java EE 6 (CDI and JTA?)
    text
    copied!<p>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.</p> <p>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:</p> <pre><code>@Stateless public class MyEJB { @PersistenceContext private EntityManager em; // methods that use the JPA entity manager... } </code></pre> <p>Then, within my own methods, I can use <code>em</code> to get at a JPA EntityManager. Whatever methods I write will (by default) automatically create or join up with an existing transaction.</p> <p>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?</p> <pre><code>@Stateless public class MyEJB { @Resource private PersistenceManager em; // methods that use the JDO persistence manager... } </code></pre> <p>But this guesswork leaves me with more questions than answers.</p> <ol> <li>How do I tell Glassfish or whatever my Java EE 6 application server turns out to be, how to make the PersistenceManagerFactory and how to use it to generate PersistenceManagers for me?</li> <li>Do I have to do anything special to achieve JTA? I'd like to be using container managed transactions if possible.</li> <li>Can I set this up to use JNDI to find my JDBC connection?</li> <li>Are there magical files that need to exist to trigger the behavior I want? (I'm looking at you, empty persistence.xml)</li> </ol> <p>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.</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload