ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Issenmann <b.issenm...@labsoft.fr>
Subject Re: Transaction Rollback not working with iBatis + Spring
Date Wed, 21 Jul 2010 18:02:35 GMT
Vinaya Tirikkovalluru <vinaya.tirikkovalluru <at> converge.com> writes:

> 
> Sorry!! I missed the thread.
> Does it give you a runtime exception? Only if the code throws a runtime
> exception the transaction will be rolled back
> 
> Vinaya

I have a runtime exception, transaction is rolled back. When i run the SQL
manually on oracle it's ok.
But with the dao i got a constraint integrity violation. It's like the inserts
go in the wrong order (complains about the first table id missing).
Or i'm wrong with the dao.

Here is my code

public class LotTest extends DAOManagerTest {

    @Test
    public void testInsert(){
    	
    	DAOFactory.daoMgr.startTransaction();
    	try {
        	LotDAO dao = (LotDAO)DAOFactory.daoMgr.getDao(LotDAO.class);
        	Lot lot = new Lot();
        	lot.setIdlot("201000000008");
        	//lot.setNumhistolot(new Short("1"));
        	lot.setIdlotamm("20char");
        	dao.insert(lot);
        	
        	HistoLotDAO dao2 =
(HistoLotDAO)DAOFactory.daoMgr.getDao(HistoLotDAO.class);
        	HistoLot histo = new HistoLot();
        	histo.setIdlot("201000000008");
        	histo.setNumhistolot(new Short("1"));
        	histo.setIdetatlot("EC");
        	histo.setDateetatlot(new Date());
        	histo.setInfoetatlot("20char");
        	dao2.insert(histo);
        	
        	DAOFactory.daoMgr.commitTransaction();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DAOFactory.daoMgr.endTransaction();
        }
    }
}

Thanks,
Bruno


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message