Last few days I was thinking about transactions which can be manipulated by the 
client. But till now I've no good solution. I want to have a bean which 
transactions can be started, rollback and commit by the client. I want to have 
a solution, where client can rollback only last transaction (not everything).

I've created simple stateful bean:


  | @TransactionManagement(TransactionManagementType.CONTAINER)
  | @FlushMode(FlushModeType.NEVER)
  | @Stateful
  | public class TransactionsStateful implements TransactionsStatefulLocal {
  | 
  |     @PersistenceContext(unitName = "ksiegi", type = 
PersistenceContextType.TRANSACTION)
  |     protected EntityManager em;
  | 
  |     @Resource
  |     protected SessionContext ctx;
  | 
  | 
  |     public void commit() {
  |             em.flush();
  |     }
  | 
  |     @TransactionAttribute(TransactionAttributeType.REQUIRED)
  |     public void rollback() {
  |             throw new RamzesException("Rollback");
  |     }
  | 
  | 
  |     private short tmpId = 0;
  | 
  |     @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
  |     public void a() {
  |             TypDzial typ = new TypDzial();
  |             typ.setNazwa("zooo32");
  |             em.persist(typ);
  |             tmpId = typ.getId();
  |     }
  | }
  | 

I run this code using:


  | local.a();
  | try {
  |     
  |     local.rollback();
  | } catch (RamzesException e) {
  | }
  | local.commit();
  | 
But the data was stored, even though I've thrown an exception using rollback 
method :( Yes, I know that I've catched the exception but client will be 
executing methods this way - he can rollback only last transaction, not all.

Is there any chance to rollback only last transaction? 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3912037#3912037

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3912037


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to