0 Replies Latest reply on Mar 20, 2007 5:23 PM by Greg Zoller

    Master/Detail Problem

    Greg Zoller Newbie


      I am having trouble with a Master/Detail relationship between Project/Expense. I have a Project screen containing a list of expenses (<h:dataTable>) and a computed total expense (@Formula field in Project ).

      * After adding a new expense I'm redirected back to Project.xhtml but my computed total expense value is wrong...its the old value--until I manually reload the page using the browser.

      * Deleting an Expense always works great for some reason--calculated totals updated and display w/o crashing.

      * If I edit an expense and redirect back to Project.xhtml sometimes the computed total value is correctly shown and other times I get a Hibernate exception like this:

      15:52:17,327 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.paragon.spurs.model.Capex#11]
       at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1699)

      I'm not sure if these are two issues are part of the same problem or not.

      Do I need to invalidate objects in Project.xhtml when I redirect back so the read fresh from the db? (If so, how can I do that?)

      Am I handling conversation scope right?

      From Project.xhtml (initiate edit and create new Expense)
      <s:button view="/CapexEdit.xhtml"
       <f:param name="projectProjectId" value="#{projectHome.instance.projectId}"/>
       <f:param name="capexCapexId" value="#{capex.capexId}"/>
       <f:param name="capexFrom" value="Project.xhtml"/>
      <!-- SNIP! -->
      <s:button view="/CapexEdit.xhtml"
       value="Add Capex"
       <f:param name="projectProjectId" value="#{projectHome.instance.projectId}"/>
       <f:param name="capexFrom" value="Project.xhtml"/>
       <f:param name="capexCapexId"/>

      Lots more code--Let me know if it would help to see something in particular.

      Thanks for any hints--getting a bit warped after several days not being able to get anywhere with this.