-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: AbstractPlatformTransactionManager
PostPosted: Wed Aug 09, 2006 2:46 pm 
Newbie

Joined: Wed Aug 09, 2006 2:36 pm
Posts: 2
Hi,

I'm trying to make my services transactional by using AbstractPlatformTransactionManager (with a HibernateTransactionManager instance via IoC). Here is my code:

protected ModelAndView handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object, BindException bindException) throws Exception {

TransactionStatus ts = null;
ArrayList libros = null;

try{
Libro libro = (Libro)object;
ts = getTransactionManager().getTransaction(null);
libros = librosDAO.selectLibroByTematica(Libros.TEMATICA);
libro.setISBN("gonzalo isbn");
librosDAO.updateLibro(libro);
Libro libro2 = new Libro();
libro2.setTematica("2");
libro2.setTitulo("nuevo titulo");
libro2.setPaginas(libro.getPaginas());
librosDAO.insertLibro(libro2);
getTransactionManager().commit(ts);
}catch(DataAccessException e){
getTransactionManager().rollback(ts);
e.printStackTrace();
}

The fact is that I think I don't really understand how spring does really do it to manage hibernate transactions. When does the transaction starts? I haven't such method like "tx.doBeginTransaction()", so, when does it start?
Also, I don't really understand how Spring manages sessions with HibernateDaoSupport and HibernateTemplate. I've been seeing this classes source code, and I don't really catch when sessions are opened and closed, so I know how to use it, but not really know how it works :-/

Thanks for the help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 25, 2006 6:17 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
The transaction begins when you call getTransaction(null).
Because this method calls doBegin(Object transaction, TransactionDefinition definition)

Please, don't forget to rate.
Venga, no seas perezoso.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.