Announcement Announcement Module
Collapse
No announcement yet.
Insert Update and Delete in single query using HibernateTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Insert Update and Delete in single query using HibernateTemplate

    I want to Insert/Update/Delete from DB in a single query using Hibernate template then which query do i need to use?

    I tried using saveupdate/saveUpdateAll it is updating and inserting the records but not deleting.

    For e.g.

    Employee object has a list of Address objects.
    Initially i have 2 address object set in Employee object and i remove one object and call saveupdate or saveupdateall or merge method of hibernate template still it is not deleting one record from DB.

    Need help!
    Thanks.

  • #2
    Then you have something wrong in your mapping... The fact that you delete it from a collection doesn't mean it is deleted from the database (the relation between the 2 is deleted!). If you want to delete the address you need to specify delete-orphan (which is only supported by hibernate and not JPA!).

    Comment


    • #3
      Hi Marten,
      Thanks for your reply.
      I used orphan-removal=true in my annotations and it worked with hibernate template's merge method.

      Comment

      Working...
      X