Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

configuration

 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference b/w



and

 
Christian Bauer
author
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only one of them works Please see the API documentation, you'll need it sooner or later.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Programmatic Configuration

An instance of net.sf.hibernate.cfg.Configuration represents an entire set of mappings of an application's Java types to a SQL database. The Configuration is used to build a (immutable)` SessionFactory. The mappings are compiled from various XML mapping files.

You may obtain a Configuration instance by instantiating it directly. Heres an example of setting up a datastore from mappings defined in two XML configuration files (in the classpath):


An alternative (sometimes better) way is to let Hibernate load a mapping file using getResourceAsStream():



Then Hibernate will look for mapping files named /org/hibernate/autcion/Item.hbm.xml and /org/hibernate/autcion/Bid.hbm.xml in the classpath. This approach eliminates any hardcoded filenames.

A Configuration also specifies various optional properties:



A Configuration is intended as a configuration-time object, to be discarded once a SessionFactory is built.
[ September 01, 2004: Message edited by: Somkiat Puisungnoen ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic