I'm using Hibernate 2.0.3.
My mapping files and value objects where generated with Middlegen R3.
I'm having problems inserting an object.
-----------------
Mapping files
-----------------
OpTurno
<?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>
<!--
Created by Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="pt.vo.OpTurno"
table="op_turnos"
>
<composite-id name="comp_id" class="pt.vo.OpTurnoPK">
<key-property
name="dataTurno"
column="data_turno"
type="java.sql.Date"
length="4"
/>
<!-- bi-directional many-to-one association to Turno -->
<key-many-to-one
name="turno"
class="pt.vo.Turno"
>
<column name="turno_fk" />
</key-many-to-one>
<!-- bi-directional many-to-one association to Op -->
<key-many-to-one
name="op"
class="pt.vo.Op"
>
<column name="op_fk" />
</key-many-to-one>
</composite-id>
<property
name="userId"
type="java.lang.String"
column="user_id"
not-null="true"
length="10"
/>
<property
name="dtHr"
type="java.sql.Timestamp"
column="dt_hr"
not-null="true"
length="8"
/>
<!-- associations -->
<!-- bi-directional one-to-one association to ControloVolante -->
<one-to-one
name="controloVolante"
class="pt.vo.ControloVolante"
outer-join="auto"
constrained="true"
/>
<!-- bi-directional one-to-one association to OpControloMonotorizacao -->
<one-to-one
name="opControloMonotorizacao"
class="pt.vo.OpControloMonotorizacao"
outer-join="auto"
constrained="true"
/>
<!-- bi-directional one-to-many association to OpControloInicio -->
<set
name="opControloInicios"
lazy="true"
inverse="true"
>
<key>
<column name="op_fk" />
<column name="turno_fk" />
<column name="data_turno_fk" />
</key>
<one-to-many
class="pt.vo.OpControloInicio"
/>
</set>
<!-- bi-directional one-to-many association to OpControloRejeicao -->
<set
name="opControloRejeicaos"
lazy="true"
inverse="true"
>
<key>
<column name="op_fk" />
<column name="turno_fk" />
<column name="data_turno_fk" />
</key>
<one-to-many
class="pt.vo.OpControloRejeicao"
/>
</set>
<!-- bi-directional one-to-one association to OpControloProducao -->
<one-to-one
name="opControloProducao"
class="pt.vo.OpControloProducao"
outer-join="auto"
constrained="true"
/>
<!-- bi-directional one-to-many association to OpControloParagem -->
<set
name="opControloParagems"
lazy="true"
inverse="true"
>
<key>
<column name="op_fk" />
<column name="turno_fk" />
<column name="data_turno_fk" />
</key>
<one-to-many
class="pt.vo.OpControloParagem"
/>
</set>
</class>
</hibernate-mapping>
OpControloProducao
<?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>
<!--
Created by Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="pt.vo.OpControloProducao"
table="op_controlo_producao"
>
<composite-id name="comp_id" class="pt.vo.OpControloProducaoPK">
<!-- bi-directional one-to-one association to OpTurno -->
<key-many-to-one
name="opTurno"
class="pt.vo.OpTurno"
>
<column name="op_fk" />
<column name="turno_fk" />
<column name="data_turno_fk" />
</key-many-to-one>
</composite-id>
<property
name="totalProducao"
type="int"
column="total_producao"
length="4"
/>
<property
name="userId"
type="java.lang.String"
column="user_id"
not-null="true"
length="10"
/>
<property
name="dtHr"
type="java.sql.Timestamp"
column="dt_hr"
not-null="true"
length="8"
/>
<!-- associations -->
<!-- bi-directional one-to-one association to OpTurno -->
<one-to-one
name="opTurno"
class="pt.vo.OpTurno"
outer-join="auto"
/>
</class>
</hibernate-mapping>
---------
Result
---------
It keeps giving me:
Hibernate: insert into op_controlo_producao (total_producao, user_id, dt_hr, op_fk, turno_fk, data_turno_fk) values (?, ?, ?, ?, ?, ?)
WARN : SQL Error: 0, SQLState: null
ERROR: ERROR: Bad int8 external representation "2003-12-16"
ERROR: Could not synchronize database state with session
java.sql.SQLException: ERROR: Bad int8 external representation "2003-12-16"
( ... )
I'm doing "println" on all the variables and the "set's" are being done correctly.
Is it a problem to use date's as PK in Hibernate?
Please help. It's making me crazy.