I have a simple J2SE program that I'm working with, and I'm curious how to get a JDBC Connection that's on the same transaction as Entity Manager work.
Specifically:
[code]
public void contrivedExample() {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("pu");
EntityManager em;
em = emf.createEntityManager();
em.getTransaction().begin();
Customer cust = em.find(Customer.class, 1);
cust.setName("Bob Eubanks");
Connection c = ????; // What goes here??
PreparedStatement ps = c.prepareStatement("insert into log(msg) values ('inserted a customer')");
ps.executeUpdate();
ps.close();
c.close();
em.getTransaction().commit();
}
[/code]
So, basically, I want to mix JDBC with EntityManager work, but I want them to share the same transaction. How do I do this?
[Message sent by forum member 'whartung' (whartung)]
http://forums.java.net/jive/thread.jspa?messageID=229413