14 Replies Latest reply on Jun 22, 2012 8:28 AM by clementlalanne

    Application Framework: EntityHome and EntityQuery

    kwutzke

      There has been a discussion some time ago:


      Seam Application Framework (EntityHome, QueryHome)


      I wonder what the status is today. Can anyone help? I'd really like to have an improved version of that framework. Especially EntityQuery could need better handling of WHERE conditions.


      So what's the status of the AF?


      Karsten

        • 1. Re: Application Framework: EntityHome and EntityQuery
          lightguard

          We're still debating it a bit. We actually need to get a sticky in place with the info. You can look through archives of the seam-dev mailing list for what we have talked about.

          • 2. Re: Application Framework: EntityHome and EntityQuery
            blabno

            Check this out
            http://artifactory.it-crowd.com.pl/libs-snapshot-local/pl/com/it-crowd/seam3-persistence-framework/1.0.0-SNAPSHOT/seam3-persistence-framework-1.0.0-SNAPSHOT.jar


            We've ported classes from seam2 and added some minor enhencements. In 2 weeks I will blog about new features and how to use EntityHome and EntityQuery as real DAO decoupled from view layer.


            • 3. Re: Application Framework: EntityHome and EntityQuery
              blabno

              btw. if you're interested in source code: http://it-crowd.com.pl/svn/seam3-persistence-framework/trunk.

              • 4. Re: Application Framework: EntityHome and EntityQuery
                cankara
                Bernard, i can not use your library with seam 3 booking-example. Can i exclude some of your dependencies or all of them because they are used in booking example too. I need your help please!

                Dependencies, which seam booking-example uses:

                        <dependency>
                            <groupId>org.jboss.solder</groupId>
                            <artifactId>solder-tooling</artifactId>
                            <scope>provided</scope>
                            <optional>true</optional>
                        </dependency>

                        <dependency>
                            <groupId>org.jboss.solder</groupId>
                            <artifactId>solder-impl</artifactId>
                        </dependency>

                        <dependency>
                            <groupId>org.hibernate</groupId>
                            <artifactId>hibernate-jpamodelgen</artifactId>
                            <version>${jpamodelgen.version}</version>
                            <scope>provided</scope>
                            <!-- Excluded Hibernate-provided JPA API because it's provided by the Java EE 6 dependencies -->
                            <exclusions>
                                <exclusion>
                                    <groupId>org.hibernate.javax.persistence</groupId>
                                    <artifactId>hibernate-jpa-2.0-api</artifactId>
                                </exclusion>
                            </exclusions>
                        </dependency>
                   
                        <dependency>
                            <groupId>org.jboss.seam.faces</groupId>
                            <artifactId>seam-faces</artifactId>
                            <scope>compile</scope><!-- Temporary workaround for GLASSFISH-17184 -->
                        </dependency>
                       
                        <dependency>
                            <groupId>org.jboss.seam.international</groupId>
                            <artifactId>seam-international</artifactId>
                        </dependency>
                       
                        <dependency>
                           <groupId>org.jboss.seam.security</groupId>
                           <artifactId>seam-security</artifactId>
                           <scope>compile</scope>
                        </dependency>
                       
                        <dependency>
                           <groupId>org.jboss.seam.transaction</groupId>
                           <artifactId>seam-transaction</artifactId>
                           <scope>compile</scope>
                        </dependency>
                       
                        <dependency>
                            <groupId>org.picketlink.idm</groupId>
                            <artifactId>picketlink-idm-core</artifactId>
                            <version>1.5.0.Alpha02</version>
                        </dependency>
                       
                        <dependency>
                            <groupId>com.ocpsoft</groupId>
                            <artifactId>ocpsoft-pretty-time</artifactId>
                            <version>1.0.6</version>
                        </dependency>

                        <dependency>
                            <groupId>com.ocpsoft</groupId>
                            <artifactId>prettyfaces-jsf2</artifactId>
                            <version>3.2.0</version>
                        </dependency>
                       
                        <dependency>
                            <groupId>commons-digester</groupId>
                            <artifactId>commons-digester</artifactId>
                            <version>2.1</version>
                        </dependency>
                       
                        <!-- Bean Validation Implementation; provides portable constraints @NotEmpty, @Email and @Url -->
                        <!-- Hibernate Validator is the only JSR-303 implementation at the moment, so we can assume it's provided -->
                        <!-- TODO Move Hibernate Validator to app server specific sections -->
                        <dependency>
                            <groupId>org.hibernate.</groupId>
                            <artifactId>hibernate-validator</artifactId>
                            <version>4.1.0.Final</version>
                            <scope>provided</scope>
                        </dependency>

                        <dependency>
                            <groupId>joda-time</groupId>
                            <artifactId>joda-time</artifactId>
                        </dependency>

                        <dependency>
                            <groupId>org.jboss.spec</groupId>
                            <artifactId>jboss-javaee-6.0</artifactId>
                            <type>pom</type>
                            <scope>provided</scope>
                        </dependency>  
                • 5. Re: Application Framework: EntityHome and EntityQuery
                  cankara
                  I get this exception, if i deploy my applicaton:

                  Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [EntityManager] with qualifiers [@Default] at injection point [[field] @Inject private pl.com.it_crowd.seam.framework.converter.EntityConverter.entityManager]
                  • 6. Re: Application Framework: EntityHome and EntityQuery
                    blabno

                    If you have in your app a different version of one of those artifacts then you may exclude them.


                    As to the exception you have no SMPC defined i guess.

                    • 7. Re: Application Framework: EntityHome and EntityQuery
                      cankara
                      Thank you for your reply.

                      I changed the annotation in class pl.com.it_crowd.seam.framework.converter.EntityConverter as follows:

                      from

                      @Inject
                      private EntityManager entityManager;

                      to

                      @PersistenceContext
                      private EntityManager entityManager;

                      I could deploy it.

                      But now i get this exception, if i want to persist something which extends EntityHome:

                      org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308 Unable to resolve any beans for Types: [interface javax.persistence.EntityManager]; Bindings: [@javax.enterprise.inject.Default()]
                           at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:707)
                           at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:96)
                           at de.persistence.EntityHome.getEntityManager(EntityHome.java:55)
                           at de.persistence.EntityHome.joinTransaction(EntityHome.java:125)
                           at de.persistence.Home.getInstance(Home.java:124)


                      I use @PersistenceContext to inject an EntityManager, because the seam 3 booking-example uses it and because i have only one persistence unit.

                      Should i change it to SMPC and how?
                      • 8. Re: Application Framework: EntityHome and EntityQuery
                        blabno

                        You should inject the EntityManager as you do in other beans. It should work with @PersistenceContext if you use it.

                        • 9. Re: Application Framework: EntityHome and EntityQuery
                          clementlalanne

                          Hello Bernard and Can.

                          I'm trying to migrate a Seam 2 application to Seam 3 and I have the same issues as Can had. So I changed :

                           

                          @Inject

                          private EntityManager entityManager;

                           

                          to

                          @PersistenceContext

                          private EntityManager entityManager;

                           

                          in EntityConverter.java, and

                           

                          @Inject

                          protected Instance<EntityManager> entityManagerInstance;

                           

                          to

                          @PersistenceContext

                          protected Instance<EntityManager> entityManagerInstance;

                           

                          in EntityHome.java.

                           

                          When running my code I get the following exception :

                           

                          java.lang.IllegalArgumentException: Can not set javax.enterprise.inject.Instance field pl.com.it_crowd.seam.framework.EntityHome.entityManagerInstance to org.jboss.as.jpa.container.TransactionScopedEntityManager

                           

                          Here is my beanHome declaration :

                           

                          @Named("clientHome")   

                          @ConversationScoped

                          public class ClientHome extends EntityHome<Client> {

                          ...

                          }

                           

                          do you have any ideas?

                           

                          Thanks,

                           

                          Clément

                          • 10. Re: Application Framework: EntityHome and EntityQuery
                            gkarakoc

                            Hi Clément,

                             

                            if you use seam managed persistence context (SMPC) you don't need change the annotation to @PersistenceContext.

                             

                            http://seamframework.org/Seam3/PersistenceModule

                             

                            http://docs.jboss.org/seam/3/persistence/latest/reference/en-US/html_single/#d0e211

                            • 11. Re: Application Framework: EntityHome and EntityQuery
                              clementlalanne

                              Thanks for your fast answer Gurcan.

                              I tried to set a SMPC but I get the same exceptions as before.

                               

                              Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [EntityManager] with qualifiers [@Default] at injection point [[field] @Inject private pl.com.it_crowd.seam.framework.converter.EntityConverter.entityManager]

                               

                              maybe I'm doing it wrong :

                               

                              public class EntityManagerProducer

                              {

                                  @ExtensionManaged

                                  @Produces

                                  @PersistenceUnit(unitName = "oraclePU")

                                  @Dependent

                                  EntityManagerFactory producerField;

                               

                              }

                              Do I have to declare something in beans.xml or web.xml ?

                               

                              I tried many things according to topics on the forum, but none of them worked..

                               

                              what do you think ?

                               

                              Clément

                              • 12. Re: Application Framework: EntityHome and EntityQuery
                                blabno

                                No beans.xml nor web.xml modifications are required. Are you sure that you bundle seam-persistence-impl with your app?

                                • 13. Re: Application Framework: EntityHome and EntityQuery
                                  clementlalanne

                                  Thanks,

                                  actually yes, seam-persistence-impl was missing...
                                  Now I'm fighting against several exceptions at deployment. I think they are dependencies exceptions like this one :


                                  org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [ELContext] with qualifiers [@Default] at injection point [[parameter 1] of [constructor] @Inject public org.jboss.solder.el.Expressions(ELContext, ExpressionFactory)]. Possible dependencies [[Producer Method [ELContext] with qualifiers [@Any @Default] declared as [[method] @Produces org.jboss.solder.el.ELContextProducer.createELContext()], Producer Method [ELContext] with qualifiers [@Any @Default] declared as [[method] @Produces org.jboss.seam.solder.el.ELContextProducer.createELContext()]]

                                   

                                  ... I'm working on it

                                   

                                   

                                  • 14. Re: Application Framework: EntityHome and EntityQuery
                                    clementlalanne

                                    I realized that my pom.xml was a terrible mess. After fixing it, everything is working fine !

                                     

                                    Thanks for your help !