1 Reply Latest reply on Feb 9, 2006 4:17 PM by epbernard

    Why does a aread only operation require a transaction?

    thhal

      I have a stateless session bean with a method annotated with the transaction attribute type SUPPORTS. The method performs a read-only query. 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? How do I perform a read-only query without enforcing a new transaction?

      TIA
      Thomas Hallgren