3 Replies Latest reply on Jul 3, 2007 9:14 AM by pmuir

    convertEntity with GF+Toplink

    trouby

      Hey,

      I'm trying to use <s:convertEntity/> Seam's tag under GF+Toplink but I get the following exception:

      java.lang.ClassCastException: oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl cannot be cast to org.hibernate.Session
      


      Shouldn't it support Toplink's entityManager as well?



      In persistence.xml I declare a PU as:
      <persistence-unit name="pu1" transaction-type="JTA">
      ...data source... etc etc...
      


      In web.xml I have the PU resource reference as:
      <persistence-unit-ref>
       <persistence-unit-ref-name>edm_acc_em</persistence-unit-ref-name>
       <persistence-unit-name>pu1</persistence-unit-name>
       </persistence-unit-ref>
      


      In components.xml I declare the managed persistence conext as:
      <core:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:comp/env/edm_acc_em"/>
      



      It kinda work well when I try to use s:selectItems with queries defined in 'framework:entity-query', but with the entityConverter it fails,



      As always,
      Many thanks,


      Asaf.

        • 1. Re: convertEntity with GF+Toplink
          gavin.king

          You need to write a org.jboss.seam.persistence.PersistenceProvider for TopLink. If you do, please contribute it back to the Seam project.

          • 2. Re: convertEntity with GF+Toplink
            trouby

            I'll work on it later on,

            But of course I will :-)


            Cheers.

            • 3. Re: convertEntity with GF+Toplink
              pmuir

              Start by creating a class

              @Name("org.jboss.seam.persistence.persistenceProvider")
              @Scope(ScopeType.STATELESS)
              @BypassInterceptors
              @Install(classDependencies="something.TopLink.Specific", genericDependencies=ManagedPersistenceContext.class)
              public class TopLinkPersistenceProvider extends PersistenceProvider {
              
              }


              This will then take precedence over HibernatePeristenceProvider (as discussed elsewhere it is still on your cp due to using an old Hibernate Annotations for validator support), and will just use the basic EJB3 PeristenceProvider.