Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-01-2009
Member
 
Join Date: Nov 2008
Posts: 20
HibernateTemplate and transaction

Hello

That is, for example, I have this code:

Quote:
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
Reply With Quote
  #2  
Old 15-01-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
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.
Reply With Quote
  #3  
Old 15-01-2009
Member
 
Join Date: May 2008
Posts: 2,008
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 ().
Reply With Quote
  #4  
Old 15-01-2009
Member
 
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:

Quote:
of public of class Of orderDAO of extends Of hibernateDaoSupport (

of public Of orderDAO () (
super ();

)

of public Of order of getOrderById (int id) (


)

)
Reply With Quote
  #5  
Old 15-01-2009
Member
 
Join Date: May 2008
Posts: 2,008
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
Reply With Quote
  #6  
Old 15-01-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 07:00 AM.