*
The moose likes Spring and the fly likes update(String entityName, Object entity) in HibernateTemplate - How to use this method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "update(String entityName, Object entity) in HibernateTemplate - How to use this method?" Watch "update(String entityName, Object entity) in HibernateTemplate - How to use this method?" New topic
Author

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

Priya Franko
Greenhorn

Joined: Aug 29, 2011
Posts: 1
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

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: update(String entityName, Object entity) in HibernateTemplate - How to use this method?