If you are wondering what happened after March 2005, well, Null Pointer moved to its own home. Please do follow me there.

Monday, November 17, 2003

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();

now:



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 connetion but when it came to using JNDI datasoure 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 soloution had nothing to do with Hibernate. Infact 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.


Quick Resources:



1: Hibernate is an open-source object/relational persistence framework and query service for Java.

World's first Hindi blogzine

I feel elated in presenting Nirantar , World's first Hindi blogzine. It has been the result of untiring efforts of so many Hindi blogger...