This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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?
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.
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.