One more question from my side ... If I have a stateless service (Stateless Session Bean) as facade (say GlobalService) which methods invokes several other services (again SLSBs, say FooService and BarService):
@Stateless
@Remote(GlobalService.class)
@TransactionManagement(TransactionManagementType.CONTAINER)
public class GlobalServiceBean implements GlobalService{
private Logger log = Logger.getLogger(GlobalServiceBean.class);
@EJB
private FooService fooService;
@EJB
private BarService barService;
public void createFoo(Foo foo, Bar bar) throws WrappedGoneBadException{
fooService.create(foo); // bang here
barService.create(bar); // no bang here
All methods at FooService (as well as BarService, which looks pretty much the same) annotated as requiring a new transaction:
@Stateless
@Remote(FooService.class)
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public class FooServiceBean implements FooService{
public Foo save(Foo foo){
... // exception here
Presumed FooServiceBean persists some objects of type 'Foo' and during this, an unchecked exception (DuplicateKeyException) will be thrown does this affect the 'surrounding' transaction to be rolled back or will it be ignored and Bar will be created?
My initial thought have been, it will not affect the transaction but Jboss proved me wrong ...
Is this the behaviour one can expect, am I wrong and if so ... how to isolate the both of them: Foo to cause an exception and obviously not saved but Bar to be saved?