Results 1 to 2 of 2

Thread: Handling Transaction

  1. #1
    Join Date
    Jan 2005
    Posts
    9

    Default Handling Transaction

    now i want to handle transaction, so i write service class like this:
    public String insertDataDictionary(String xmlParam) {
    try {
    ......
    dataDictionaryDao.insertDataDictionary(model);
    dataDictionaryDao.deleteDataDictionary(111);
    } catch (Exception e) {
    return ErrorMessage.errorXml(e);
    }
    return SuccessMessage.successXml();
    }

    when i didn't use try... catch , roll back is perfect..

    but when i used tyr ..catch , rollback didn't work..
    how can i make service class..???

    ** this is DAO class ***
    public void deleteDataDictionary(int wordno){
    int result = this.executeUpdate("DataDictionary.deleteDataDicti onary", new Integer(
    wordno));
    if (result == 0)
    new RuntimeException("There is no data !! ");
    }
    have a good day

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    when i didn't use try... catch , roll back is perfect..
    You need to throw a RuntimeException or a checked exception with a rollback rule (which is why it worked without a try...catch). Otherwise you have to do progrommatic transaction rollback.

Similar Threads

  1. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  2. Replies: 0
    Last Post: Jun 6th, 2005, 06:22 AM
  3. Replies: 6
    Last Post: May 17th, 2005, 11:38 PM
  4. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  5. Transaction pb Hibernate/MySQL
    By syluser in forum Data
    Replies: 2
    Last Post: Aug 28th, 2004, 02:40 PM

Posting Permissions

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