1 Reply Latest reply on Aug 28, 2009 1:12 PM by José Moreira

    persisting entity in JSF action method rsults in exception "unknown entity ..."

    José Moreira Newbie

      i'm testing seam and developing a simple registration form:


      UserHome.java:


      @Name("userHome")
      @Scope(ScopeType.CONVERSATION)
      public class UserHome extends EntityHome<User> {

              @Factory("user")
              public User initPerson() {
                      return getInstance();
              }
      }


      RegisterActionBean.java


      @Stateless
      @Name("registerAction")
      public class RegisterActionBean implements RegisterActionLocal {

              @In(required=false) UserHome userHome;

              /**
               *
               * @return
               */
              public String register() {
                      return userHome.persist(); // exception here
              }
      }


      but i'm getting:
      javax.ejb.EJBTransactionRolledbackException: Unknown entity: com.tradestr.model.accounts.User


      if i instead inject @PersistenceContext directly it works:



      @Stateless
      @Name("registerAction")
      public class RegisterActionBean implements RegisterActionLocal {

              @In(required=false) UserHome userHome;

              @PersistenceContext
              EntityManager entityManager;
              /**
               *
               * @return
               */
              public String register() {
                      entityManager.persist(userHome.getInstance());
              }


      what am i doing wrong?


        • 1. Re: persisting entity in JSF action method rsults in exception "unknown entity ..."
          José Moreira Newbie

          Sorry bad formating.


          i'm testing seam and developing a simple registration form:


          UserHome.java:




          @Name("userHome")
          @Scope(ScopeType.CONVERSATION)
          public class UserHome extends EntityHome<User> {
          
               @Factory("user")
               public User initPerson() {
                    return getInstance();
               }
          }





          RegisterActionBean.java


          @Stateless
          @Name("registerAction")
          public class RegisterActionBean implements RegisterActionLocal {
          
               @In(required=false) UserHome userHome;
          
               /**
                * 
                * @return
                */
               public String register() {
                    return userHome.persist(); // exception here
               }
          }



          but i'm getting:
          javax.ejb.EJBTransactionRolledbackException: Unknown entity: com.tradestr.model.accounts.User


          if i instead inject @PersistenceContext directly it works:



          @Stateless
          @Name("registerAction")
          public class RegisterActionBean implements RegisterActionLocal {
          
               @In(required=false) UserHome userHome;
          
               @PersistenceContext
               EntityManager entityManager;
               /**
                * 
                * @return
                */
               public String register() {
                    entityManager.persist(userHome.getInstance());
               }




          what am i doing wrong?