1 2 Previous Next 15 Replies Latest reply on Apr 27, 2006 12:48 PM by pbrewer_uk

    Help understanding validation

    pbrewer_uk

      I have a simple screen that displays a list of entities, which can be clicked on to start a two step wizard-style editor. If some invalid data has been entered and I click save on the final step I get an InvalidStateException from hibernate instead of a nice validation message.

      I've looked at the examples and thought these were the required steps to ensure hibernate validation works:


      1. Add validation tags to the entity bean methods (E.g. @Length).
      2. In the seam managed bean add an @Valid tag to the value (entity) being updated.
      3. Add an @Invalid tag to the action method.


      However, I must be missing something because I get the exception below. I have also posted the code that I think applies to the steps I mentioned above. If I should post any further code I'll be happy to do so.

      Any help with this would be greatly appreciated (I should mention I'm using Seam 1.0beta2, MyFaces 1.1 and Oracle10XE)

      Thanks in advance, Peter.

      Entity Bean:
      @Entity
      @Table(name="WIZ_TEST")
      public class WizardTest implements Serializable {
      ...
       @Column(name="VALUE1")
       @Length(min=0, max=50, message="Value 1 must be less than 50 characters long.")
       public String getPage1Value () {
       return page1Value;
       }
       public void setPage1Value ( String page1Value ) {
       this.page1Value = page1Value;
       }
      ...
      }
      


      Seam Managed Bean:
      @Stateful
      @Name ( "wizard" )
      @Scope ( ScopeType.CONVERSATION )
      @Interceptors ( SeamInterceptor.class )
      public class WizardAction implements Wizard {
      
       @In(create=true)
       private EntityManager em;
      
       @Valid
       @Out(scope = ScopeType.CONVERSATION, required = false)
       private WizardTest selection ;
      
      ...
      
       @End ( ifOutcome = "saved" )
       @IfInvalid( outcome = Outcome.REDISPLAY )
       public String save() {
       em.persist(selection);
       return "saved" ;
       }
      }
      


      Exception stack trace:
      org.hibernate.validator.InvalidStateException: validation failed for: uk.co.iblocks.jobsite.data.WizardTest
       at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:104)
       at org.hibernate.validator.event.ValidateEventListener.onPreUpdate(ValidateEventListener.java:132)
       at org.hibernate.action.EntityUpdateAction.preUpdate(EntityUpdateAction.java:209)
       at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:64)
       at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
       at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
       at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
       at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:3056)
       at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:2614)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:1191)
       ... 31 more


        • 1. Re: Help understanding validation
          gavin.king

          Its impossible to tell, since you truncated both your stacktrace AND your code, but this almost always happens because some other method - not the action method - is being called transactionally and committing the txn before the action method gets called.

          Judicious application of @TransactionAttribute(NOT_SUPPORTED) should solve this problem.

          • 2. Re: Help understanding validation
            pbrewer_uk

            Thanks for the quick reply Gavin, and apologies for not providing enough info to start with. I've posted the full code for the seam managed bean, the facelet code and the full stack-trace.

            I do use the @TransactionAttribute(NOT_SUPPORTED) - but perhaps just not in the right places? (I added the tx attribs to prevent auto-flushing between wizard steps).

            Seam managed bean:

            @Stateful
            @Name ( "wizard" )
            @Scope ( ScopeType.CONVERSATION )
            @Interceptors ( SeamInterceptor.class )
            public class WizardAction implements Wizard {
            
             private static final Logger LOG = Logger.getLogger( WizardAction.class );
            
             @In(create=true)
             private EntityManager em;
            
             @Resource
             SessionContext ctx;
            
             @DataModel
             private List<WizardTest> testList;
            
             @DataModelSelectionIndex
             private int selectionIndex ;
            
             @Valid
             @Out(scope = ScopeType.CONVERSATION, required = false)
             private WizardTest selection ;
            
             @Factory ( "testList" )
             public void buildTestList () {
             LOG.info("Entity Manager Class: " + em.getClass().getName());
             testList = em.createNamedQuery( "wizardTest.findAll" ).getResultList() ;
             }
            
             @Begin
             public String editItem() {
             selection = testList.get(selectionIndex) ;
             return "page1" ;
             }
            
             @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
             public String next() {
             return "page2" ;
             }
             @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
             public String prev() {
             return "page1" ;
             }
            
             @End
             public String cancel() {
             em.refresh(selection);
             return "list" ;
             }
            
             @End ( ifOutcome = "saved" )
             @IfInvalid( outcome = Outcome.REDISPLAY )
             public String save() {
             em.persist(selection);
             return "saved" ;
             }
            
             @Remove
             @Destroy
             public void destroy() { }
            
            }
            


            TestList.xhtml - lists the entities:
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            
            <html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:t="http://myfaces.apache.org/tomahawk"
             xmlns:h="http://java.sun.com/jsf/html">
             <head>
             <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
             </head>
            
             <body id="pgMainMenu">
             <f:view>
             <h:form>
             <p>Select An Item to edit...</p>
             <t:dataList id="listData"
             var="rowData"
             value="#{testList}"
             rowIndexVar="rowIndex">
            
             <h:commandLink action="#{wizard.editItem}" value="Edit Item #{rowData.id}" />
             <br />
             </t:dataList>
             </h:form>
             </f:view>
             </body>
            </html>
            


            TestPage1.xhtml - Step 1 of wizard:
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            
            <html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:h="http://java.sun.com/jsf/html">
             <head>
             <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
             </head>
            
             <body id="pgMainMenu">
             <f:view>
             <h:form>
             <table>
             <tr>
             <td>
             <h:outputLabel for="listId">ID:</h:outputLabel>
             </td>
             <td>
             <h:outputText id="listId" value="#{selection.id}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="v1">Value1: </h:outputLabel>
             </td>
             <td>
             <h:inputText id="v1" value="#{selection.page1Value}" />
             </td>
             </tr>
            
             <tr>
             <td colspan="2" class="text-align: right;">
             <h:commandLink action="#{wizard.cancel}">
             Cancel
             </h:commandLink>
            
             <h:commandLink action="#{wizard.prev}">
             Back
             </h:commandLink>
            
             <h:commandLink action="#{wizard.next}">
             Next
             </h:commandLink>
             </td>
            
             </tr>
             </table>
             </h:form>
             </f:view>
             </body>
            </html>
            


            TestPage2.xhtml - 2nd (final) Step of wizard:
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            
            <html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:h="http://java.sun.com/jsf/html">
             <head>
             <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
             </head>
            
             <body id="pgMainMenu">
             <f:view>
             <h:form>
             <table>
             <tr>
             <td>
             <h:outputLabel for="listId">ID:</h:outputLabel>
             </td>
             <td>
             <h:outputText id="listId" value="#{selection.id}" />
             </td>
             </tr>
             <tr>
             <td>
             <h:outputLabel for="v2">Value2: </h:outputLabel>
             </td>
             <td>
             <h:inputText id="v2" value="#{selection.page2Value}" />
             </td>
             </tr>
             <tr>
             <td colspan="2">
             <h:messages showDetail="true" />
             </td>
             </tr>
             <tr>
             <td colspan="2" class="text-align: right;">
             <h:commandLink action="#{wizard.cancel}">
             Cancel
             </h:commandLink>
            
             <h:commandLink action="#{wizard.prev}">
             Back
             </h:commandLink>
            
             <h:commandLink action="#{wizard.save}">
             Save
             </h:commandLink>
             </td>
             </tr>
             </table>
             </h:form>
             </f:view>
             </body>
            </html>
            


            Full stack trace:
            25-04 15:43:47 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
            java.lang.IllegalStateException: Could not commit transaction
             at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.commit(SeamExtendedManagedPersistencePhaseListener.java:83)
             at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.afterPhase(SeamExtendedManagedPersistencePhaseListener.java:49)
             at org.apache.myfaces.lifecycle.LifecycleImpl.informPhaseListenersAfter(LifecycleImpl.java:519)
             at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:332)
             at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:84)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:44)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
             at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
             at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
             at java.lang.Thread.run(Thread.java:595)
            Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1145976022084/22, BranchQual=null:1145976022084, localId=0:22], status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.validator.InvalidStateException: validation failed for: uk.co.iblocks.jobsite.data.WizardTest)
             at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:1283)
             at org.jboss.tm.TxManager.commit(TxManager.java:587)
             at org.jboss.ejb3.embedded.UserTransactionImpl.commit(UserTransactionImpl.java:90)
             at org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener.commit(SeamExtendedManagedPersistencePhaseListener.java:77)
             ... 28 more
            Caused by: org.hibernate.validator.InvalidStateException: validation failed for: uk.co.iblocks.jobsite.data.WizardTest
             at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:104)
             at org.hibernate.validator.event.ValidateEventListener.onPreUpdate(ValidateEventListener.java:132)
             at org.hibernate.action.EntityUpdateAction.preUpdate(EntityUpdateAction.java:209)
             at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:64)
             at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
             at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
             at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
             at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
             at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
             at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
             at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
             at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
             at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:3056)
             at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:2614)
             at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:1191)
             ... 31 more
            


            • 3. Re: Help understanding validation
              gavin.king

              Oh, yes, thats right, there is an issue I am aware of here, that actually some other users have already run into.

              The problem is that the ValidationInterceptor only runs *after* the EJB txn has already started, so any changes to managed objects (as opposed to new or detached objects) will end up being flushed when the txn ends.

              Possible solutions:

              (1) Use detached objects in the view instead of managed objects (this may be a PITA, however)

              (2) Add refreshEntities=true to @IfInvalid (may not be the functionality you want, however)

              (3) Patch Seam and add the following lines to ValidationInterceptor

              if (component.getType()==ComponentType.JAVA_BEAN)
               {
               Transactions.setUserTransactionRollbackOnly();
               }
               else
               {
               Transactions.getEJBContext().setRollbackOnly();
               }


              just before:
              return ifInvalid.outcome();


              Now, this is not *strictly* supported by the EJB spec, since a PC is considered hosed after a txn rollback. However, I just tested it with Seam 1.0.0.CR1 and JBoss 4.0.4.CR2 and it seemed to work.

              (4) Wait for me to figure out a better solution ;-) Actually I have had this on my todo list, but kind of forgot how urgent it is....

              • 4. Re: Help understanding validation
                gavin.king

                 

                "gavin.king@jboss.com" wrote:

                (3) Patch Seam and add the following lines to ValidationInterceptor


                Ah. This probably does not help, since a tx rollback results in the PC getting clear()ed, so your managed objects would become detached, same ol PITA.

                OK, let me think of something else.

                • 5. Re: Help understanding validation
                  pbrewer_uk

                  I agree, I'd rather not go down the path of detached objects - as you rightly say a PITA.

                  I'm not sure that I fully understand the problem, but would manually setting the EntityManager's flushMode to FlushMode.NEVER solve the issue?

                  For example, doing something like adding an action listener to set the flush mode:

                   public void checkValidation(ActionEvent ae) {
                   org.hibernate.ejb.EntityManagerImpl e = (org.hibernate.ejb.EntityManagerImpl) em ;
                   e.getSession().setFlushMode(FlushMode.NEVER);
                   }
                  
                   @End ( ifOutcome = "saved" )
                   @IfInvalid( outcome = Outcome.REDISPLAY)
                   @TransactionAttribute(REQUIRED)
                   public String save() {
                   em.persist( selection );
                   em.flush() ;
                   return "saved";
                   }
                  


                  And in the view:
                   <h:commandLink action="#{wizard.save}" actionListener="#{wizard.checkValidation}">
                   Save
                   </h:commandLink>
                  


                  • 6. Re: Help understanding validation
                    gavin.king

                     

                    I'm not sure that I fully understand the problem, but would manually setting the EntityManager's flushMode to FlushMode.NEVER solve the issue?


                    Yes, that is a good workaround.

                    • 7. Re: Help understanding validation
                      pbrewer_uk

                      Hmm, I just tried manually setting the flushmode to NEVER but it appears the flushmode is set to AUTO when the transaction starts, so still throws the original InvalidStateException.

                      Is there anything I can do to prevent the flushmode going back to auto? Or is there any other work-around I could try? Otherwise it is back to detached objects for me!

                      26-04 10:16:33 DEBUG [Lifecycle] >>> Begin web request
                      26-04 10:16:33 DEBUG [Component] instantiating Seam component: org.jboss.seam.core.manager
                      26-04 10:16:33 DEBUG [Manager] Restoring conversation with id: 2
                      26-04 10:16:33 DEBUG [Contexts] found in application context: org.jboss.seam.core.init
                      26-04 10:16:33 DEBUG [SeamPhaseListener] After restore view, conversation context: ConversationContext(2)
                      26-04 10:16:33 DEBUG [LoggedInPhaseListener] afterPhase view id: /TestPage2.xhtml
                      26-04 10:16:33 DEBUG [LoggedInPhaseListener] Page /TestPage2.xhtml does not require authentication.
                      26-04 10:16:33 DEBUG [SeamVariableResolver] resolving name: selection
                      26-04 10:16:33 DEBUG [Contexts] found in conversation context: selection
                      26-04 10:16:33 DEBUG [SeamVariableResolver] resolved name to seam component
                      26-04 10:16:33 DEBUG [SeamVariableResolver] resolving name: selection
                      26-04 10:16:33 DEBUG [Contexts] found in conversation context: selection
                      26-04 10:16:33 DEBUG [SeamVariableResolver] resolved name to seam component
                      26-04 10:16:33 DEBUG [SeamVariableResolver] resolving name: selection
                      26-04 10:16:33 DEBUG [Contexts] found in conversation context: selection
                      26-04 10:16:33 DEBUG [SeamVariableResolver] resolved name to seam component
                      26-04 10:16:33 DEBUG [SeamVariableResolver] resolving name: wizard
                      26-04 10:16:33 DEBUG [Contexts] found in conversation context: wizard
                      26-04 10:16:33 DEBUG [SeamVariableResolver] resolved name to seam component
                      26-04 10:16:33 DEBUG [Contexts] found in application context: facesContext
                      26-04 10:16:33 DEBUG [Contexts] found in conversation context: jobsiteEm
                      26-04 10:16:33 DEBUG [JDBCContext] successfully registered Synchronization
                      26-04 10:16:33 DEBUG [AbstractEntityManagerImpl] Transaction activated, move to FlushMode AUTO
                      26-04 10:16:33 DEBUG [SessionImpl] setting flush mode to: AUTO
                      26-04 10:16:33 DEBUG [Component] selected row: -1
                      26-04 10:16:33 DEBUG [SessionImpl] setting flush mode to: NEVER
                      26-04 10:16:33 DEBUG [WizardAction] Set session to flush mode: NEVER
                      26-04 10:16:33 DEBUG [SeamVariableResolver] resolving name: wizard
                      26-04 10:16:33 DEBUG [Contexts] found in conversation context: wizard
                      26-04 10:16:33 DEBUG [SeamVariableResolver] resolved name to seam component
                      26-04 10:16:33 DEBUG [Contexts] found in application context: facesContext
                      26-04 10:16:33 DEBUG [Contexts] found in conversation context: jobsiteEm
                      26-04 10:16:33 DEBUG [AbstractEntityManagerImpl] Transaction activated, move to FlushMode AUTO
                       26-04 10:16:33 DEBUG [SessionImpl] setting flush mode to: AUTO
                      26-04 10:16:33 DEBUG [Component] selected row: -1
                      26-04 10:16:33 DEBUG [ValidationInterceptor] invalid component state: wizard
                      26-04 10:16:33 DEBUG [ValidationInterceptor] invalid value:page2Value Value 2 must be less than 50 characters long., clientId: null
                      26-04 10:16:33 DEBUG [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
                      26-04 10:16:33 DEBUG [SeamExtendedManagedPersistencePhaseListener] committing transaction
                      26-04 10:16:33 DEBUG [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
                      26-04 10:16:33 DEBUG [CacheSynchronization] transaction before completion callback
                      26-04 10:16:33 DEBUG [CacheSynchronization] automatically flushing session
                      26-04 10:16:33 DEBUG [SessionImpl] automatically flushing session
                      26-04 10:16:33 DEBUG [AbstractFlushingEventListener] flushing session
                      26-04 10:16:33 DEBUG [AbstractFlushingEventListener] processing flush-time cascades
                      26-04 10:16:33 DEBUG [AbstractFlushingEventListener] dirty checking collections
                      26-04 10:16:33 DEBUG [AbstractFlushingEventListener] Flushing entities and processing referenced collections
                      26-04 10:16:33 DEBUG [AbstractEntityPersister] uk.co.iblocks.jobsite.data.WizardTest.page2Value is dirty
                      26-04 10:16:33 DEBUG [DefaultFlushEntityEventListener] Updating entity: [uk.co.iblocks.jobsite.data.WizardTest#1]
                      26-04 10:16:33 DEBUG [AbstractFlushingEventListener] Processing unreferenced collections
                      26-04 10:16:33 DEBUG [AbstractFlushingEventListener] Scheduling collection removes/(re)creates/updates
                      26-04 10:16:33 DEBUG [AbstractFlushingEventListener] Flushed: 0 insertions, 1 updates, 0 deletions to 4 objects
                      26-04 10:16:33 DEBUG [AbstractFlushingEventListener] Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
                      26-04 10:16:33 DEBUG [Printer] listing entities:
                      26-04 10:16:33 DEBUG [Printer] uk.co.iblocks.jobsite.data.WizardTest{page2Value=6, id=3, page1Value=3}
                      26-04 10:16:33 DEBUG [Printer] uk.co.iblocks.jobsite.data.WizardTest{page2Value=4, id=2, page1Value=2}
                      26-04 10:16:33 DEBUG [Printer] uk.co.iblocks.jobsite.data.WizardTest{page2Value=012345678901234567890123456789012345678901234567890123456789, id=1, page1Value=50}
                      26-04 10:16:33 DEBUG [Printer] uk.co.iblocks.jobsite.data.WizardTest{page2Value=8, id=4, page1Value=4}
                      26-04 10:16:33 DEBUG [AbstractFlushingEventListener] executing flush
                      26-04 10:16:33 DEBUG [JDBCContext] before transaction completion
                      26-04 10:16:33 DEBUG [SessionImpl] before transaction completion
                      26-04 10:16:33 DEBUG [CacheSynchronization] transaction after completion callback, status: 4
                      26-04 10:16:33 DEBUG [JDBCContext] after transaction completion
                      26-04 10:16:33 DEBUG [SessionImpl] after transaction completion
                      26-04 10:16:33 ERROR [SeamExceptionFilter] uncaught exception handled by Seam
                      
                      etc...
                      


                      • 8. Re: Help understanding validation
                        gavin.king

                        dunno, ask emmanuel in the hibernate forum

                        • 9. Re: Help understanding validation
                          pbrewer_uk

                          Well, I've just upgraded to RC2 and the wizard-style app works as I originally intended without any of the workarounds! Well worth the upgrade, but I'm a little curious as to how was solved - was it you Gavin, or is this a mystery to you too?

                          Anyway, thanks for all the help!

                          • 10. Re: Help understanding validation
                            gavin.king

                            Um, as far as I am aware this problem is still a problem. It is actually a deep conceptual problem in how the spec says extended persistence contexts should behave...


                            I just committed the <s:validate/> and <s:validateAll/> tags, as a different kind of solution.

                            eg:


                            <h:inputText value="#{model.attribute}"><s:validate/></h:inputText>


                            And:

                            <s:validateAll>
                             <h:inputText value="#{user.name}"/>
                             <h:inputText value="#{user.email}"/>
                             ...
                            </s:validateAll>


                            • 11. Re: Help understanding validation
                              pbrewer_uk

                              Hmm, well I'm a little puzzled then - as far as I can tell the upgrade totally solved my problem! I did post to the hibernate forum (see http://forum.hibernate.org/viewtopic.php?t=958651).

                              emmanual wrote


                              so be sure to use Seam 1.0.0 CR1 or 2
                              It comes bundled with Hibernate EntityMaanger 3.1 beta7 which fix this issue


                              Perhaps he wasn't talking about my workaround issue (the session flushMode resetting) - but the original validation issue? I'm not sure if my Hibernate post was all that clear.

                              Would the validation tags (temporarily at least) replace the need for the @Valid and @IfInvalid annotations?

                              • 12. Re: Help understanding validation
                                gavin.king

                                Ohyeah, sure, meddling the flushmode is a good workaround, and if Emmanuel has fixed that, you are goodtogo.

                                But check out my new facelets tags as an alternative approach.

                                • 13. Re: Help understanding validation
                                  pbrewer_uk

                                  The trouble is, I'm not using *any* workaround at the moment. The code that throws an InvalidStateException in Seam beta2 just works in Seam RC2!

                                  While I'm not compaining that it works, it does leave me feeling a little uneasy.

                                  • 14. Re: Help understanding validation
                                    gavin.king

                                    Um ... are you sure that it is not updating the database with the invalid values?

                                    1 2 Previous Next