• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with full rollback in EJB3 CMT

 
Marian Mroz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I've got a problem with following project. We've two classes: CustomerValue and AddressValue which are join one-to-many (Customer can have many Addresses), and I have one EJB3 bean which is responsible for transaction - putting elements into database. When I try to put some wrong data in AddressValue class (with null value), EJB does rollback but only for AddressValue entity, not for whole CustomerValue entity. CustomerValue is created at the begining, then I add AddressValue and do save() by EJB.

What should I do to do rollback for whole CustomerValue when in one of his part (eg AddressValue) will notify that it can't be added to DB (PersistanceException)?

I work on JBoss 5.0.0GA, Java 1.6.0_12-b04
Code with setting is attached bellow:

AddressValue:

CustomerValue:

CustomerDAO:

CustomerDAOTest

persistance.xml



Thanks for help
 
Chris Hurd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You appear to be defining your datasource twice once in the <jta-data-source and once as hibernate properties.

First remove the following hibernate properties:


Then make sure that your DefaultDS.xml file has auto-commit set to false
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!