[jboss-user] [EJB 3.0] - Re: need help for Transaction Attribute Types

grdzeli_kaci do-not-reply at jboss.com
Wed Aug 15 05:11:19 EDT 2007


Hello Ta
Great Thanks for your post, i tried to this for couple of moth and could not resolve this problem.
and ok, i did what you say i got another problem when i tried to persist in one method whats ok, there is no information persisted in database, but when i tried to flush on other method i got an error : javax.persistence.TransactionRequiredException.
my example now looks like :

  | package com.magti.businesslayer.ejb3Fasade;
  | 
  | import javax.ejb.EJB;
  | import javax.ejb.Remote;
  | import javax.ejb.Remove;
  | import javax.ejb.Stateful;
  | import javax.ejb.Stateless;
  | import javax.ejb.TransactionAttribute;
  | import javax.ejb.TransactionAttributeType;
  | import javax.ejb.TransactionManagement;
  | import javax.ejb.TransactionManagementType;
  | import javax.persistence.EntityManager;
  | import javax.persistence.PersistenceContext;
  | import javax.persistence.PersistenceContextType;
  | import javax.persistence.PersistenceProperty;
  | 
  | import com.magti.businesslayer.ejb3Fasade.TestFasade;
  | import com.magti.businesslayer.ejb3entity.oracle.Test;
  | 
  | @Stateful
  | @Remote(TestFasade.class)
  | @TransactionManagement(TransactionManagementType.BEAN)
  | public class TestFasadeBean implements TestFasade {
  | 
  | 	@PersistenceContext(
  | 				type = PersistenceContextType.EXTENDED, 
  | 				properties = @PersistenceProperty(
  | 								name = "org.hibernate.flushMode", 
  | 								value = "MANUAL"))
  | 	EntityManager oracleManager;
  | 	Test test;
  | 	
  | 	public Long create() {
  | 		try {
  | 			test = new Test();
  | 			test.setAge(21L);
  | 			test.setName("adsdasd");
  | 			test.setSurname("asdasd");
  | 			oracleManager.persist(test);
  | 			return test.getId();
  | 		} catch (Exception e) {
  | 			e.printStackTrace();
  | 			return 0L;
  | 		}
  | 	}
  | 
  | 	public void comit() {
  | 		try {
  | 			oracleManager.flush();
  | 		} catch (Exception e) {
  | 			e.printStackTrace();
  | 		}
  | 	}
  | }
  | 

when i tried to flush, i got this exception : javax.persistence.TransactionRequiredException. 
i tried to use @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
and 
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
but it could not resolve problem :(

have any idea ?

Thanks again ALRubinger In advance.

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

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



More information about the jboss-user mailing list