The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

mchaia (1) [Avatar] Offline
Hi there,
Is anybody using Hibernate with WebSphere successfully? Just wondering if someone can give me some link to a tutorial or step-by-step guide.
I'm giving up. I really tried everything I could but I got no success (basically, JNDI problems with Hibernate Session Factory)
TIA. Regards,
logical_way (2) [Avatar] Offline
Re: WebSphere 5.1
I used Hibernate with WebSphere 5.0 and used JNDI based datasource lookup. It's Simple man, first let me tell you what to change :
1] The properties file that comes default with hibernate
needs to be changed uncomment the last-line

hibernate.jndi.url iiop://localhost:900/
change above url to iiop://localhost:2809/

And in the datasouce tab of your servers .wsi file make your datasource, even if you are not using DB2 you can create your own user defined datasouce and jdbc provider provided you have it's jdbc driver implmentation. I used MySql driver by creating my own user defined jdbc provider it worked.

That's all and you will have to set the hibernate properties file and cfg in class path and ideally things should work.

As far as step by step tutorial is concerned I think you don't need it. After all hibernate framework only needs the jndi context and provider url.Only thing you have to do is create proper datasource and bind it with some name in your [WebSphere] jndi context.

Hibernate probably doing something like this that you would have done had there been no JNDI lookup facility in hibernate:

Context ctx = new InitialContext(<your property file name having initcontext class and provider url properly set>smilie;
Object objTemp = ctx.lookup(<your datasource binding name>smilie;
dsDataSource = (DataSource) PortableRemoteObject.narrow(objTemp, DataSource.class);

Use this dsDataSource object for getting connection.