gavin wrote:
Please trim your code down to just what is relevant to the error. TIA
sorry, I'm new posting here...
Hibernate version: 2.1.3
Mapping documents:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Mapping files -->
<mapping resource="model/TipoDocumento.hbm.xml"/>
<mapping resource="model/DatosPersonales.hbm.xml"/>
<mapping resource="model/TipoAnsesCode.hbm.xml"/>
<mapping resource="model/TipoEstadoCivil.hbm.xml"/>
<mapping resource="model/TipoACargo.hbm.xml"/>
<mapping resource="model/TipoEscolaridad.hbm.xml"/>
<mapping resource="model/Agente.hbm.xml"/>
<mapping resource="model/Familiar.hbm.xml"/>
<mapping resource="model/TipoParentesco.hbm.xml"/>
<mapping resource="model/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="model">
<class name="Agente" table="Agente"
discriminator-value="N">
<id name="internalId">
<generator class="native"/>
</id>
<property name="log"> <column name="log" length="24" />
</property>
<property name="foja"> <column name="foja" length="6" />
</property>
<property name="fechaIngreso"> <column name="fechaIngreso"
length="8" />
</property>
<many-to-one name="datosPersonales" class="model.DatosPersonales"
cascade="save-update" column="datosPersonalesId" />
....
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
package="model">
<class name="DatosPersonales" table="DatosPersonales"
discriminator-value="N">
<id name="internalId">
<generator class="native"/>
</id>
......
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Agente ag = (Agente) obj;
try {
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
session.save(ag);
tx.commit();
HibernateUtil.closeSession();
} catch (Exception e) {
System.out.println("EXCEPTION!!! on write de Agente: ");
e.printStackTrace();
}
ADVERTENCIA: SQL Error: -530, SQLState: 23503
26/08/2004 11:24:31 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: DB2 SQL error: SQLCODE: -530, SQLSTATE: 23503, SQLERRMC: MPISANO.AGENTE.FK74C60A20C07A4404
26/08/2004 11:24:31 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
ADVERTENCIA: SQL Error: -530, SQLState: 23503
26/08/2004 11:24:31 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: DB2 SQL error: SQLCODE: -530, SQLSTATE: 23503, SQLERRMC: MPISANO.AGENTE.FK74C60A20C07A4404
26/08/2004 11:24:31 net.sf.hibernate.JDBCException <init>
GRAVE: could not insert: [model.Agente]
com.ibm.db2.jcc.a.SqlException: DB2 SQL error: SQLCODE: -530, SQLSTATE: 23503, SQLERRMC: MPISANO.AGENTE.FK74C60A20C07A4404
at com.ibm.db2.jcc.a.cq.d(cq.java:1234)
at com.ibm.db2.jcc.c.bc.k(bc.java:345)
at com.ibm.db2.jcc.c.bc.a(bc.java:63)
at com.ibm.db2.jcc.c.q.a(q.java:64)
at com.ibm.db2.jcc.c.bp.c(bp.java:266)
at com.ibm.db2.jcc.a.cr.V(cr.java:1412)
at com.ibm.db2.jcc.a.cr.d(cr.java:1939)
at com.ibm.db2.jcc.a.cr.R(cr.java:440)
at com.ibm.db2.jcc.a.cr.executeUpdate(cr.java:423)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:526)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:925)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:850)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:768)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:731)
at model.AgentePersisterImpl.write(AgentePersisterImpl.java:51)
at model.MainWrite.main(MainWrite.java:221)
net.sf.hibernate.JDBCException: could not insert: [model.Agente]
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:556)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:925)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:850)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:768)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:731)
at model.AgentePersisterImpl.write(AgentePersisterImpl.java:51)
at model.MainWrite.main(MainWrite.java:221)
Caused by: com.ibm.db2.jcc.a.SqlException: DB2 SQL error: SQLCODE: -530, SQLSTATE: 23503, SQLERRMC: MPISANO.AGENTE.FK74C60A20C07A4404
at com.ibm.db2.jcc.a.cq.d(cq.java:1234)
at com.ibm.db2.jcc.c.bc.k(bc.java:345)
at com.ibm.db2.jcc.c.bc.a(bc.java:63)
at com.ibm.db2.jcc.c.q.a(q.java:64)
at com.ibm.db2.jcc.c.bp.c(bp.java:266)
at com.ibm.db2.jcc.a.cr.V(cr.java:1412)
at com.ibm.db2.jcc.a.cr.d(cr.java:1939)
at com.ibm.db2.jcc.a.cr.R(cr.java:440)
at com.ibm.db2.jcc.a.cr.executeUpdate(cr.java:423)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:526)
... 8 more
EXCEPTION!!! on write de Agente: