I'm trying out different things with Hibernate for the first time and I stumbled across the following:
The reveng generated all the POJO classes and thier DAO (nameHome)
After wrestling a bit with jndi I've got working code using HibernateUtil to return the session that is bound on the jndi.
So I can do something simple like this without problem:
Code:
...
SessionFactory sf = HibernateUtil.getSessionFactory();
Session s = sf.openSession();
Transaction t = s.beingTransaction();
Customer c = (Customer)s.get("com.myapp.hibernate.obj", id)
...
I noticed that the CustomerHome generated by reveng doesn't create a transaction, for what I assume it expects the session to be open, and have a transaction assigned already. But I'm failing to see how I need to set that up.
How do I begin a transaction such that is attached to the "CurrentSession"? So I can use something like:
Code:
Customer c = CustomerHome.findByID(id)
Any pointers appreciated!
-p