0 Replies Latest reply on Aug 28, 2006 9:07 PM by Gary Cuozzo

    Exception while creating entities in SLSB

    Gary Cuozzo Newbie

      I have a SLSB method that I call from a portlet. I am trying to create an entity and also modify a many-to-many relationship.

      The exception I'm getting is:
      20:51:46,215 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null
      20:51:46,216 ERROR [JDBCExceptionReporter] failed batch
      20:51:46,217 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update

      The SLSB method code is:

      Client client = new ClientEJB(username, password, domainName);
      Role userRole = RoleEJB.findByName(em, "user");
      client.getRoles().add(userRole);
      em.persist(client);


      If I comment out adding the role, the client entity does get created just fine.

      Is there something I need to do in order to persist the new entity with the relationship? I've tried using em.flush() after creating the entity with no luck.

      I'm somewhat new to EJB3, so thanks in advance for any help,
      Gary.