Problem persisting chils class
rmcalderero.rmcalderero.wanadoo.es Feb 17, 2008 11:12 PMIn our model we have a class A and a child class A1. When we persist an A1 instance with JPA/Hibernate in a junit test case the object is persisted correctly.
However when execute exactly the same code with the entity manager indide a seam conversation the operation fails with this exception:
Hibernate: insert into Analisis (descripcion, diaSemana, emailsAdicionales, envioEmailIndicadores, envioInformeEmail, envioSMSIndicadores, estado, fecha, informeEmail, movilSMS, nombre, periodo, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 22:52:29,209 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: S1009 22:52:29,209 ERROR [JDBCExceptionReporter] Statement parameter 13 not set. 22:52:29,224 ERROR [SeamPhaseListener] uncaught exception javax.el.ELException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [org.fundacionctic.tawmonitor.model.AnalisisCerrado] at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:332) at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:341) at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58) .......................... at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:87) at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38) at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618) at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592) at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596) at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:213) ... 70 more Caused by: java.sql.SQLException: Statement parameter 13 not set. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910) at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1045) at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:693) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1404) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1318) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1303) at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) ... 85 more
The problem is the id
attribute inside the insert statement created by seam. This attribute is annotated @Id @GeneratedValue
and obviously is no set in our instance; it must me managed by hibernate.
So is there some special consideration in Seam when persisting parent/child objects?