I have a simple
java program. There are 10 classes, 4 of which are @Entity beans using hibernate 4 to interface with the database. It runs the old-fashioned way from the command line, eg "java -jar myapp.jar". When I implemented hibernate in this app I followed some rather old examples that include a HibernateUtil.java class.
Hibernate sessions are grabbed via
boilerplate stuff, as far as I can tell.
It works fine the way it is, but I decided to re-design the thing using CDI. I'm wondering if there is some nifty, new way to grab those hibernate sessions, maybe using CDI? But this is not an
J2EE app, there is nothing enterprise-y about it. When I try to inject a persistence context or entity manager it comes up "null". And I can't find a single discussion or example of doing this that is not a J2EE app.
Is it possible to acquire a hibernate session using CDI or some other nifty annotation in a plain old java program? Or is this only possible in a J2EE context?
Am I misunderstanding something fundamental? (would not be the first time!)
TDR