3 Replies Latest reply on Mar 4, 2006 11:26 AM by Jérémy Goldschmidt

    Error storing objects with ejb3 entity

    Jérémy Goldschmidt Newbie

      Hello,

      I have trouble when trying to store objects with ejb3 entities. I follow the trailer (http://trailblazer.demo.jboss.com/EJB3Trail/) which is a very good support. However when I deploy my ear I have the following errors:

      FATAL [PersistenceXmlLoader] ejb3essaiPerst JTA

      and when I use the EntityManager to persist an object, an exception is throwned:

      00:09:25,872 WARN [JDBCExceptionReporter] SQL Error: -22, SQLState: S0002
      00:09:25,872 ERROR [JDBCExceptionReporter] Table not found in statement [insert into t_tech (prenom, nom) values (?, ?)]
      00:09:25,872 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.exception.SQLGrammarException: could not insert: [fr.aulnette.essai.ejb3.entity.TechnicienBOBean]
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      [...]

      Caused by: java.sql.SQLException: Table not found in statement [insert into t_tech (prenom, nom) values (?, ?)]
      at org.hsqldb.jdbc.Util.throwError(Unknown Source)
      [...]

      In fact the table creation doesn't appear anymore in the hsqldb log but I don't know why.

      The Entity bean code:
      -------------------------

      @Entity
      @Table(name="t_tech")
      public class TechnicienBOBean implements Serializable {

      String nom;
      String prenom;
      //SiteBOBean site;

      @Id
      public String getNom() {
      return nom;
      }

      public void setNom(String nom) {
      this.nom = nom;
      }
      [...]
      }


      The Session Stateless bean code:
      ---------------------------------------

      @Stateless
      public class TechnicienBSBean implements TechnicienBSI, TechnicienRemoteBSI {
      @PersistenceContext(unitName="ejb3essaiPerst")
      protected EntityManager em;

      public void storeTechnicienInDB(String nom, String prenom) {
      TechnicienBOBean technicienEntity = new TechnicienBOBean();
      technicienEntity.setNom(nom);
      technicienEntity.setPrenom(prenom);
      em.persist(technicienEntity);
      }
      [...]
      }


      The persistence.xml file is embedded into the META-INF directory of my ejb findTechnicien-ejb.jar:
      -------------------


      <persistence-unit name="ejb3essaiPerst">
      <jta-data-source>java:/DefaultDS</jta-data-source>
      </persistence-unit>


      The application.xml file is embedded into the META-INF directory of my ear:
      -------------------


      <display-name>findTechnicien</display-name>

      findTechnicien-ejb.jar



      Some help would be very appreciated because i have no more ideas.

      thank you,

      --
      Jeremy Goldschmidt
      France