Results 1 to 6 of 6

Thread: HibernateTemplate and transaction

  1. #1
    Join Date
    Nov 2008
    Posts
    20

    HibernateTemplate and transaction

    Hello

    That is, for example, I have this code:

    getHibernateTemplate (). save (user);
    getHibernateTemplate (). save (order1);
    getHibernateTemplate (). save (order2);
    I think some of these three operations united into a single transaction? ie that if the least of these operations do a mistake then all three do the same please give proper suggestion thanks

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: HibernateTemplate and transaction

    1. Use the transaction management software. To do this, see TransactionCallback.
    2. Use a declaratory transaction management. This is done at the configuration level g. In this case, it can be a method transformation. That is, starting with the transaction method, and closes when you exit. This method has many possiblity. For example, you can specify at what exceptions should revert the transaction or to specify the transaction read only.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: HibernateTemplate and transaction

    Remove Of hibernateTemplate of calls to of the of respective DAO, but of the of code of itself and then in a Of service. In of which, depending on of the of approach, or work of with of the of transaction of directly or of mark of through of annotation or of through of configuration, as of described of above.Usually of does of not of directly of cause of the of methods Of hibenrateTemplate. Make of the DAO, which of causes of create, which of has of delegated of this Of hibernateTemplate.save ().

  4. #4
    Join Date
    Nov 2008
    Posts
    20

    Re: HibernateTemplate and transaction

    for example, for of operations of with of the of orders, I have OforderService, there Of orderDAO, I appeal to Of orderService, it in of turn to Of orderDao,

    and OrderDAO of example of looks of like of this:

    of public of class Of orderDAO of extends Of hibernateDaoSupport (

    of public Of orderDAO () (
    super ();

    )

    of public Of order of getOrderById (int id) (


    )

    )

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: HibernateTemplate and transaction

    based solely on the manager of the transaction, which is located in the most getHibernateTemplate (). This is the manager and determine whether it is a transaction or more. Again, it was not clear getHibernateTemplate () returns a copy, or different? If one instance, the high probability is one session, and one transaction. But specify that only in most cases. Because it is possible to set up such a code, and for different sessions and in different transactions and for all that you want. That something is his charm

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    Re: HibernateTemplate and transaction

    Service could use several different methods of DAO. Depending on the situation, we can quickly make this method useful, and just as quickly removed from the transaction. Service should not know anything about how the interface is implemented DAO.

Similar Threads

  1. How to get effective transaction in oracle
    By CRiley in forum Software Development
    Replies: 5
    Last Post: 27-02-2010, 02:21 AM
  2. Cannot shrink transaction log file in in sql
    By Deepest BLUE in forum Software Development
    Replies: 3
    Last Post: 06-06-2009, 01:00 PM
  3. How to use Transaction Management in JDBC
    By VinFanatic in forum Software Development
    Replies: 3
    Last Post: 25-04-2009, 12:39 PM
  4. Effect of transaction on inventory
    By Antrix in forum Software Development
    Replies: 2
    Last Post: 21-04-2009, 11:12 AM
  5. Overclock and Transaction Booster!
    By machok in forum Overclocking & Computer Modification
    Replies: 3
    Last Post: 14-02-2009, 10:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,613,744.43752 seconds with 17 queries