Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Configuring Hibernate !!!

 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is configuring Hibernate by JNDI bound SessionFactory and DataSource same. If not what's the difference. And how do we do them each of them.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A SessionFactory and a DataSource are different things. A SessionFactory is a Hibernate term; it is a class that provides Sessions based on a Configuration. A Session is a connection to a DataSource. DataSources are a JDBC term, not a Hibernate term. They are supply a mechanism to connect to a database.

How you configure a SessionFactory is documented on the Hibernate web site.

How you configure a DataSource depends on the container you are using. Which one are you using?
 
Siddharth Bhargava
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that SessionFactory and Datasource are different things. I also know the details about SessionFactory, Session and Datasource. But I have heard somewhere that we can configure Hibernate through 2 ways through a JNDI bound SessionFactory and through datasource and in both we use JNDI. I am using JBoss as a container.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But I have heard somewhere that we can configure Hibernate through 2 ways through a JNDI bound SessionFactory and through datasource and in both we use JNDI. I am using JBoss as a container.

Where did you hear that?

The basis of Hibernate is a SessionFactory. Whether or not it is JNDI bound doesn't really matter, its just a deployment choice. You can't configure Hibernate "through a datasource". A SessionFactory uses a DataSource.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic