2

I have started learning Hibernate and have a basic question.

What is the difference between save(String entityName, Object object) and save(Object object) in the org.hibernate.Session class. Basically I want to know what the entityName parameter is in this overloaded method. I tried to look at the API but didn't glean much from there.

Bhesh Gurung
  • 50,430
  • 22
  • 93
  • 142
rasaab
  • 31
  • 3

2 Answers2

2

It's a logical name for an entity intended to match the same entity-name in a mapping file. It defaults to the class name for the current entity, but if you provide your own value, then you can use the same class with multiple different mapping files.

See http://www.martinahrer.at/2008/04/09/55/ and http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/mapping.html and http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/persistent-classes.html#persistent-classes-dynamicmodels and http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/xml.html (search for "entity-name" in each case).

Glen Best
  • 22,769
  • 3
  • 58
  • 74
0

It's Hibernate Object Identifier. It's not recommended to use this in save() method. please refer to http://www.hibernate-training-guide.com/object-identifiers.html

BigOne
  • 1
  • It's not the identifier. It's a logical name for a mapped entity - matches the entity name in a mapping file :) – Glen Best May 29 '13 at 06:04