Towards harmony with Hibernate
Never thought that leaping into Hibernate1 could be a bit tricky at this time. First there aren't many good step-by-step guide to using Hibernate and secondly all the available ones, perhaps, don't hold good for Hibernate ver 2.01, though it was released almost 6 months back. Now the porting guidelines say that it isn't much of a work but a Hibernate newbie may beg to differ. As I said it is a bit tricky. Thanks to the post of Matt that helped me on this. Basically the code portion to use Hibernate would change as follows (hey, I am just a beginner on this so I might have said something stupid):
Earlier (assuming a database entity Player with a bean of similar name for persistance) :
Datastore dStore = Hibernate.createDatastore(); dStore .storeClass(Person.class); SessionFactory sfactory = ds.buildSessionFactory();
Configuration cfg = new Configuration(); cfg .addClass(Person.class); SessionFactory sfactory = cfg.buildSessionFactory();
Now my application is hosted on Websphere Application Server (WAS) and connects to Oracle8 using JNDI datasource. I was able to talk to Oracle using Hibernate employing URL based connection but when it came to using JNDI datasource I was stuck. Posts at the Hibernate forum came with the usual replies and did not help much (may be my questions weren't good enough). As a matter of fact, I was getting the following error:
net.sf.hibernate.HibernateException: Could not find datasource: com.ibm.ejs.cm.JDBC1PhaseRF
The solution had nothing to do with Hibernate. In fact WAS was getting confused by the javax.sql classes that came with the library jdbc2_0-stdext.jar. This jar arrives with the Hibernate distribution and collided with WAS's own settings. Once I removed this jar, the problem vanished and I could connect to Oracle using Hibernate. The related thread is here. I have managed this far but I know it will take sometime before I could be in perfect harmony with Hibernate.
- Nick Heudecker's article ( covers Hibernate 2.0.1)
- Glen Smith's Hitchhiker's Guide to Hibernate
- Hibernate – External Documentation List
1: Hibernate is an open-source object/relational persistence framework and query service for Java.