2 Replies Latest reply on Feb 9, 2006 4:35 PM by Emmanuel Bernard

    Unable to get TransactionAttributeType SUPPORTS working

    Thomas Hallgren Newbie

      I have a stateless session bean with a method that creates a query using the entity manager. Since the method is read-only I don't want to force a new transaction so I use the attribute type SUPPORTS. I can't get that to work. I always get the following stack trace:

      javax.persistence.TransactionRequiredException: EntityManager must be access within a transaction
      at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getSession(ManagedEntityManagerFactory.java:124)
      at org.jboss.ejb3.entity.InjectedEntityManager.getSession(InjectedEntityManager.java:154)
      at org.jboss.ejb3.entity.InjectedEntityManager.createQuery(InjectedEntityManager.java:67)

      Why is that? Do I always have to have a transaction? Even if the operation is just read-only?

      Thomas Hallgren