4 Replies Latest reply on Oct 30, 2007 1:30 PM by Jarkko Lietolahti

    Multiple <s:convertEntity /> from different persistence mana

    Jarkko Lietolahti Novice

      Hello,
      I'm trying to figure out how use different entity managers with s:convertEntity.

      This is from Admin page which uses the adminEntityManager (EM without any restriction filters).


      <h:selectManyListbox value="#{unit.manager}" size="4">
      <s:selectItems value="#{managers}" var="yp" label="#{yp.name}" />
      <s:convertEntity />
      </h:selectManyListbox>


      Now, this fails because the s:convertEntity has been configured to use (because it's also used elsewhere/other pages) restrictedEntityManager in components.xml.

      Is there a way to use "multiple" EntityManagers aka have more than one entityConverter? I couldn't find a way to do that.


      org.hibernate.TransientObjectException: The instance was not associated with this session
      at org.hibernate.impl.SessionImpl.getIdentifier(SessionImpl.java:1375)
      at org.jboss.seam.persistence.HibernatePersistenceProvider.getId(HibernatePersistenceProvider.java:51)
      at org.jboss.seam.framework.EntityIdentifier.<init>(EntityIdentifier.java:15)
      at org.jboss.seam.ui.EntityConverterStore.put(EntityConverterStore.java:61)
      at org.jboss.seam.ui.EntityConverter.getAsString(EntityConverter.java:63)



      components.xml:
      <component name="org.jboss.seam.ui.entityConverter">
       <property name="entityManager">#{restrictedEntityManager}</property>
      </component>
      
      
      <core:managed-persistence-context name="restrictedEntityManager">
       <core:filters>
       <value>#{disabledFilter}</value>
       </core:filters>
      </core:managed-persistence-context>
      
      <core:managed-persistence-context name="adminEntityManager">
      </core:managed-persistence-context>