jQuery in Action, 2nd edition
The moose likes Object Relational Mapping and the fly likes adding .hb.xml  vs  .class in configuration Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "adding .hb.xml  vs  .class in configuration" Watch "adding .hb.xml  vs  .class in configuration" New topic
Author

adding .hb.xml vs .class in configuration

Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 205
hi guys

iam having a doubt that what is the difference between adding a hbm.xml file
vs .class to the configuration object for building the sessionfactory

let me tell you an example

iam having a table named user

Configuration configuration = new Configuration();
configuration.addClass(user.class) ;//statement 1
vs
configuration.addFile("user.hbm.xml") ;// statement 2

what is the difference between statement 1 and statement 2

regards
amir
[ July 04, 2007: Message edited by: Amirtharaj Chinnaraj ]
Chandra Sekhar
Ranch Hand

Joined: Sep 26, 2003
Posts: 90
Hi,

addClass will try to read a mapping from an application resource, using a convention.

Ex.The class foo.bar.Foo is mapped by the file foo/bar/Foo.hbm.xml.


"Luck is when opportunity meets preparation"
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 205
i will be happy if i get some

more techinical information

regards
amir
Jaikiran Pai
Saloon Keeper

Joined: Jul 20, 2005
Posts: 6718

Have a look at this Hibernate documentation. Specifically, have a look at Section 3.1 which mentions why the addClass method is considered better for creating a Configuration.


[My Blog] [JavaRanch Journal]
 
 
subject: adding .hb.xml vs .class in configuration
 
Threads others viewed
JSP/Servlet VS PHP
Statement vs. PreparedStatement
ClassNotFoundException vs NoClassDefFoundError
MyEclipse Vs RAD
WSAD Build Path vs. DD vs. Class Path
developer file tools