-->
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.  [ 1 post ] 
Author Message
 Post subject: Persistence rollback exception
PostPosted: Sun Sep 26, 2010 4:23 am 
Newbie

Joined: Sun Sep 26, 2010 4:10 am
Posts: 1
I'm persisting two entities, the second one has a unique constraint but when I try to break that constraint a javax.persistence.RollbackException: Transaction marked as rollbackOnly is thown so the first persisted entity is not rolled back. Im using the @Transactional Spring annotation, anyway here is the code , I'd appreciate very much any help :

Spring application context :
.
.
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="transactionManager" />

Service class method:

Image i= new Image();
i.setImagePath("asdfads");

Book b= new Book();
b.setTitle("aaa");

try {
//entityManager.persist(presInd);
//entityManager.persist(verbo);
entityManager.persist(i);
entityManager.persist(b);

//throw new java.lang.Exception();



return true;

} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
System.out.println("calling rooback");

Exception :
javax.persistence.RollbackException: Transaction marked as rollbackOnly


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

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.