Announcement Announcement Module
Collapse
No announcement yet.
[Hibernate] updating half an entity with HibernateTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Hibernate] updating half an entity with HibernateTemplate

    Hi, Im using Spring 3.0.5 and Hibernate 3 in my project, updating my entities with HibernateTemplate:

    getHibernateTemplate().saveOrUpdate(myEntityVO);

    But for updating just some columns of my database I need to do it with HQL with:
    getHibernateTemplate().bulkUpdate(query);
    otherwise the values of myEntityVO that I don't want to update are overwritten to NULL.

    Does anybody know a way to avoid HQL for this kind of update, using for example, Criteria?

    Thank you in advanced.

  • #2
    Code:
    e = getHIbernateTemplate().getSession().get(YourEntity.class, yourEntity.getId());
    e.setOne(yourEntity.getOne());
    e.setTwo(yourEntity.getTwo());
    ....

    Comment

    Working...
    X