• Post Reply Bookmark Topic Watch Topic
  • New Topic

adding .hb.xml vs .class in configuration  RSS feed

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i will be happy if i get some

more techinical information

regards
amir
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!