Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

update(String entityName, Object entity) in HibernateTemplate - How to use this method?

 
Priya Franko
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone please explain with the example for using
update(String entityName, Object entity)
in HibernateTemplate provided by Spring framework.

My exact doubt is
What is that entityName?

Can I use this method to update only certain required columns in the db table without affecting other data in other columns.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I don't use the HibernateTemplate but use Hibernate directly in my code. I get no benefits from the template class because from Hibernate 3.1 and higher there is no boiler plate code.

But that method will update all the fields on the entity, so the domain object instance you pass in has an name, that is either the class name or what you named it in the @Entity annotation, which no one actually does, so it is the class name


@Entity
public class Person


so I would call

template.update("Person", personInstance);

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic