Hibernate version:2.1.6
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
>
<class
name="com.apl.hibernate.crud.conad.Tpartidas"
table="PARTIDAS"
proxy="com.apl.hibernate.crud.conad.Tpartidas"
dynamic-update="true"
dynamic-insert="true"
select-before-update="false"
optimistic-lock="version"
discriminator-value="null"
>
<id
name="id"
column="ID"
type="long"
length="15"
>
<generator class="sequence">
<param name="sequence">GENIDPARTIDAS</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Tpartidas.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<version
name="version"
type="long"
column="VERSION"
access="property"
unsaved-value="undefined"
/>
<property
name="partidaId"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
>
<column
name="IDPARTIDA"
sql-type="${number7}"
/>
</property>
<many-to-one
name="tableEntradas"
class="com.apl.hibernate.crud.conad.Tentradas"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
column="IDENTRADA"
/>
<property
name="entradaId"
type="java.lang.Long"
update="true"
insert="true"
access="property"
>
<column
name="IDENTRADA"
not-null="true"
sql-type="${number15}"
/>
</property>
<property
name="bultos"
type="java.lang.Float"
update="true"
insert="true"
access="property"
>
<column
name="BULTOS"
sql-type="${number10_3}"
/>
</property>
<property
name="kilos"
type="java.lang.Float"
update="true"
insert="true"
access="property"
>
<column
name="KILOS"
sql-type="${number10_3}"
/>
</property>
<property
name="m3"
type="java.lang.Float"
update="true"
insert="true"
access="property"
>
<column
name="M3"
sql-type="${number10_3}"
/>
</property>
<property
name="mercancia"
type="java.lang.String"
update="true"
insert="true"
access="property"
>
<column
name="MERCANCIA"
sql-type="VARCHAR(100)"
/>
</property>
<property
name="estado"
type="java.lang.Short"
update="true"
insert="true"
access="property"
>
<column
name="ESTADO"
sql-type="${number4}"
/>
</property>
<property
name="valor"
type="java.lang.Float"
update="true"
insert="true"
access="property"
>
<column
name="VALOR"
sql-type="${number14_3}"
/>
</property>
<many-to-one
name="tableUbicacion"
class="com.apl.hibernate.crud.conad.Tubicacion"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
property-ref="ubicacionId"
column="IDUBICACION"
/>
<property
name="ubicacionId"
type="java.lang.String"
update="true"
insert="true"
access="property"
>
<column
name="IDUBICACION"
sql-type="VARCHAR(10)"
/>
</property>
<many-to-one
name="tableRemitente"
class="com.apl.hibernate.crud.conad.Tentidades"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
property-ref="entidadId"
column="IDREMITENTE"
/>
<property
name="remitenteId"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
>
<column
name="IDREMITENTE"
sql-type="${number7}"
/>
</property>
<many-to-one
name="tableDestinatario"
class="com.apl.hibernate.crud.conad.Tentidades"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
property-ref="entidadId"
column="IDDESTINATARIO"
/>
<property
name="destinatarioId"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
>
<column
name="IDDESTINATARIO"
sql-type="${number7}"
/>
</property>
<many-to-one
name="tableSalidas"
class="com.apl.hibernate.crud.conad.Tsalidas"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
property-ref="salidaId"
column="IDSALIDA"
/>
<property
name="salidaId"
type="java.lang.Integer"
update="true"
insert="true"
access="property"
>
<column
name="IDSALIDA"
sql-type="${number7}"
/>
</property>
<property
name="auditInfo"
type="com.apl.hibernate.util.AuditInfoType"
update="true"
insert="true"
access="property"
>
<column
name="CREADO_POR"
sql-type="VARCHAR(30)"
/>
<column
name="CREADO_FECHA"
sql-type="TIMESTAMP"
/>
<column
name="EDITADO_POR"
sql-type="VARCHAR(30)"
/>
<column
name="EDITADO_FECHA"
sql-type="TIMESTAMP"
/>
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
currentSession().load(partidas, partidaId); // Of course
currentSession().delete(partidas); // This one originates the problem
Full stack trace of any exception that occurs:
Name and version of the database you are using:Firebird 1.5.1
The generated SQL (show_sql=true):
Hibernate: update PARTIDAS set VERSION=?, IDENTRADA=?, IDUBICACION=?, IDREMITENTE=?, IDDESTINATARIO=?, CREADO_POR=?, CREADO_FECHA=?, EDITADO_POR=?, EDITADO_FECHA=? where ID=? and VERSION=?
2004-10-13 13:38:49,640 [main] WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 335544347, SQLState: HY000
2004-10-13 13:38:49,640 [main] ERROR net.sf.hibernate.util.JDBCExceptionReporter - GDS Exception. 335544347. validation error for column IDENTRADA, value "*** null ***"
2004-10-13 13:38:49,640 [main] WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 335544347, SQLState: HY000
2004-10-13 13:38:49,640 [main] ERROR net.sf.hibernate.util.JDBCExceptionReporter - GDS Exception. 335544347. validation error for column IDENTRADA, value "*** null ***"
2004-10-13 13:38:49,640 [main] ERROR net.sf.hibernate.util.JDBCExceptionReporter - could not update: [com.apl.hibernate.crud.conad.Tpartidas#30961]
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544347. validation error for column IDENTRADA, value "*** null ***"
Debug level Hibernate log excerpt:
Problem description:
As you can see, I have a many-to-one relation established using EntradaId property that, besides is a "not null" field.
Every time I issue a delete on this class I get 2 sql statements, one to set this field to null and another to delete this row. BUT as this field is not null, I get this error.
If I change this field to be nullable in my database, everything works fine.
The only problem is that this field MUST BE not null.
Besides, I have observed that if the relation is against a property-ref, everything works fine, also.
This problem only arises if the relation is against the id field of external class using foreign keys.
|