1 Reply Latest reply on Sep 21, 2010 3:15 AM by Ondrej Medek

    Session bean method - read-only transaction

    Ondrej Medek Apprentice



      is there any way, how to mark a method in @Stateless session bean as "read-only" in regards to the database transaction?


      I mean something like Spring has: it should make a "read-only" DB transaction (if JDBC driver supports that) and set the Hibernate FlushMode to NEVER. It should improve the performance, because the Hibernate would not flush the session. The Hibernate shoudl save some time, by not walking through all managed entities and checking, if something has been modified, eg. see this link.


      I have tried to mark my method as




      But my check


      {code}System.out.println("flush mode: " + HibernateHelper.getSession(this.em).getFlushMode());{code}


      prints "AUTO". Furthemore, I cannot initialize LAZY realtionships when the TransactionAttribute is set to NOT_SUPPORTED.