Results 1 to 3 of 3

Thread: How to Transaction by using HibernateTemplate

  1. #1

    Default How to Transaction by using HibernateTemplate

    I use getHibernateTemplate() method to get HibernateTemplate Object,then I use delete(Object entity) method to delete some database record,like follows:
    getHibernateTemplate().delete(entity1);
    getHibernateTemplate().delete(entity2);

    My question is I want to know if HibernateTemplate support commit and rollback? Because I want to realize following function:

    Code:
    getHibernateTemplate().setCommit("false"); 
    try{
       getHibernateTemplate().delete(entity1);  
       getHibernateTemplate().delete(entity2);
       getHibernateTemplate().commit();
    }
    catch(){
       getHibernateTemplate().rollback();
    }
    How to realize above function?
    Thanks

  2. #2
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    You can use the Hibernate API directly and don't need to use the HibernateTemplate.

    Joerg
    This post can contain insufficient information.

  3. #3
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    As Jörg said, you don't have to use HibernateTemplate. Either way however it sounds like you need to have a look at transactions.
    http://www.springframework.org/docs/...decl-explained
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •