2 Replies Latest reply on Jul 20, 2009 2:31 PM by Clinton Parham

    2.2.0.CR1 flush-mode manual LRC

    Clinton Parham Newbie

      I'm having a hard time getting Manual FlushMode to work. Or am I confused? Please help. Thanks.

      I have created a basic seam-gen project with a page, long running conversation scoped javabean and an entity bean. Even though I'm trying to set manual flushmode, any call to the bean persist method results in an insert to the database. Why?

      The page xml starts the conversation and sets the flushmode:

      <?xml version="1.0" encoding="UTF-8"?>
      <page xmlns="http://jboss.com/products/seam/pages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd" action="#{LwfcAtt.loadPage}">
           <begin-conversation join="true" flush-mode="MANUAL" />

      The backing bean:

      public class LwfcAtt {
           private Log log;
           StatusMessages statusMessages;
           private EntityManager entityManager;
           private LwfcAttendence attendence;
           public void getAllAttendeeTypes() {
                attendeeTypes = entityManager.createQuery(
                          "select t from LwfcAttendee t").getResultList();
           public void getAllEventTypes() {
                eventTypes = entityManager.createQuery("select e from LwfcEvent e")
           public void setAttendence(LwfcAttendence attendence) {
                this.attendence = attendence;
           public LwfcAttendence getAttendence() {
                // log.info(">>> FlushMode=" + entityManager.getFlushMode());
                if (attendence == null) {
                     log.info(">>> new LwfcAttendence()");
                     attendence = new LwfcAttendence();
                return attendence;
           public void persist() {
                // entityManager.flush();
           // @Begin(join = true, flushMode = FlushModeType.MANUAL)
           public void loadPage() {
           private void showFlushMode() {
                log.info(">>> FlushMode=" + entityManager.getFlushMode());
                FlushModeType flushModeType = PersistenceContexts.instance()
                log.info("[2]flushModeType.name() = " + flushModeType.name());

      Output from the showFlushMode when the page is loaded:

      22:46:49,520 INFO  [LwfcAtt] >>> FlushMode=null
      22:46:49,520 INFO  [LwfcAtt] [2]flushModeType.name() = MANUAL
      22:46:49,571 INFO  [LwfcAtt] >>> new LwfcAttendence()
      22:46:49,585 INFO  [STDOUT] Hibernate: 
              lwfcevent0_.id as id7_,
              lwfcevent0_.name as name7_ 
              seam.lwfc_event lwfcevent0_

      Output from the showFlushMode when the persist method is called:

      22:48:44,963 INFO  [LwfcAtt] >>> FlushMode=null
      22:48:44,963 INFO  [LwfcAtt] [2]flushModeType.name() = MANUAL
      22:48:44,964 INFO  [STDOUT] Hibernate: 
              (eventId, attendenceDate) 
              (?, ?)
      22:48:45,012 INFO  [LwfcAtt] >>> FlushMode=null
      22:48:45,012 INFO  [LwfcAtt] [2]flushModeType.name() = MANUAL