• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DataSource vs SessionFactory

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a hard time describing the differences between a DataSource and a SessionFactory (like what is provided by Hibernate) to a client. How they are different, what the pros and cons are for each.

If any of you can give me an example (not code but verbal example) or analogies that would be awesome.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well a DataSource is a "Connection" to the database. The Session Factory is so that you can complete "queries" on the database and include it in a Transaction if you want. The session is kind of like a Transaction in that you can do some updates and it will be in cache not hitting the "database" yet, until you commit.

Now my description is high level and not as accurate as if it was a detailed description, but it should give you a basic idea of the difference.

A DataSource defines and makes connection to the database, a Session is used to do work on the data.

Mark
 
cempaka melati
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thought of this a bit more but not sure if it is a good analogy

The datasource is like the phone line. The phone book is JNDI since the datasource you created can be looked up in the JNDI directory. SessionFactory is a lawyer that knows what his clients want (mapping objects ot database) and wanting to use the datasource phone line in order to send/store the message.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic