3 Replies Latest reply on Nov 26, 2007 9:22 AM by Sefai Tando?an

    Seam remoting and persistence

    Tamir Weiss Newbie

      I'm just starting to play with Seam remoting, and I'm having the following problem with persistence :

      My POJO actions are able to query the DB just fine, but when trying to create a new entity instnace, the persist() method seems to return without doing anything in the DB.

      I'm attaching the relevant code, persistence.xml and components.xml.

      Any help would be greatly appreciated.

       <persistence-unit name="Iou" transaction-type="JTA">
       <property name="hibernate.hbm2ddl.auto" value="${hibernate.hbm2ddl.auto}"/>
       <property name="hibernate.hbm2ddl.auto" value="update" />
       <property name="hibernate.show_sql" value="true" />
       <property name="hibernate.transaction.manager_lookup_class"
       value="org.hibernate.transaction.JBossTransactionManagerLookup" />

       <core:managed-persistence-context auto-create="true"
       entity-manager-factory="#{IouEntityManagerFactory}" name="entityManager"/>
       <core:entity-manager-factory name="IouEntityManagerFactory" persistence-unit-name="Iou"/>

      package com.iou.action;
      import java.util.List;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.Transactional;
      import org.jboss.seam.annotations.WebRemote;
      import org.jboss.seam.core.FacesMessages;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.security.Identity;
      import com.iou.entity.User;
      public class RegisterAction {
       private User currentUser;
       private EntityManager entityManager;
       Log log;
       public User register(String email, String password, String name) {
       User newUser = null;
       List existing = entityManager.createQuery(
       "select u from User u where u.email=:email").setParameter(
       "email", email).getResultList();
       if (existing.size() == 0) { // the query is executed just fine
       newUser = new User();
       entityManager.persist(newUser); //nothing is saved to the DB.
       currentUser = newUser;
       return newUser;
       } else {
       User existingUser = (User) existing.get(0);
       if (existingUser.isActive() == false) {
       log.info("User " + email + " has been activated");
       currentUser = existingUser;
       return existingUser;
       } else {
       log.info("email " + email + " already exists");
       return null;