Description:
While saving the object "newDefect", hibernate retieves the generated key from the Informix DB. While retrieving the generated key, the informix JDBC driver throw a "Method not supported" error.
Hibernate version: 2.1
Mapping documents:
Code:
<hibernate-mapping>
<class
name="be.goca.general.defects.objects.Defect"
table="defects"
>
<id
name="labelid"
type="java.lang.Integer"
column="labelid"
>
<generator class="native" />
</id>
<property
name="code"
type="java.lang.String"
column="code"
not-null="true"
length="3"
/>
<property
name="sanction"
type="java.lang.String"
column="sanction"
length="1"
/>
<property
name="malus"
type="java.lang.String"
column="malus"
length="1"
/>
<property
name="ligne"
type="java.lang.Integer"
column="ligne"
length="2"
/>
<property
name="codePrint"
type="java.lang.String"
column="code_print"
length="1"
/>
<property
name="rubr1"
type="java.lang.String"
column="rubr1"
length="2"
/>
<property
name="kwalif1"
type="java.lang.String"
column="kwalif1"
length="1"
/>
<property
name="rubr2"
type="java.lang.String"
column="rubr2"
length="2"
/>
<property
name="kwalif2"
type="java.lang.String"
column="kwalif2"
length="1"
/>
<property
name="position"
type="java.lang.Short"
column="position"
length="6"
/>
<property
name="axe"
type="java.lang.Short"
column="axe"
length="6"
/>
<property
name="startappl"
type="java.sql.Date"
column="startappl"
length="10"
/>
<property
name="endappl"
type="java.sql.Date"
column="endappl"
length="10"
/>
<property
name="utilvehic"
type="java.lang.Short"
column="utilvehic"
length="6"
/>
<!-- associations -->
<!-- uni-directional one-to-many association to Defnature -->
<set
name="defnatures"
lazy="true"
>
<key>
<column name="labelid" />
</key>
<one-to-many
class="be.goca.general.defects.objects.Defnature"
/>
</set>
<!-- uni-directional one-to-many association to Deftype -->
<set
name="deftypes"
lazy="true"
>
<key>
<column name="labelid" />
</key>
<one-to-many
class="be.goca.general.defects.objects.Deftype"
/>
</set>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class
name="be.goca.general.defects.objects.Defnature"
table="defnature"
>
<id
name="defnatureId"
type="java.lang.Integer"
column="defnatureID"
>
<generator class="native" />
</id>
<property
name="natureid"
type="int"
column="natureid"
length="6"
/>
<property
name="labeln"
type="java.lang.String"
column="labeln"
length="50"
/>
<property
name="labelf"
type="java.lang.String"
column="labelf"
length="50"
/>
<property
name="labeld"
type="java.lang.String"
column="labeld"
length="50"
/>
<!-- associations -->
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class
name="be.goca.general.defects.objects.Deftype"
table="deftype"
>
<id
name="deftypeId"
type="java.lang.Integer"
column="deftypeID"
>
<generator class="native" />
</id>
<property
name="typeid"
type="int"
column="typeid"
length="6"
/>
<property
name="labeln"
type="java.lang.String"
column="labeln"
length="50"
/>
<property
name="labelf"
type="java.lang.String"
column="labelf"
length="50"
/>
<property
name="labeld"
type="java.lang.String"
column="labeld"
length="50"
/>
<!-- associations -->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Defect newDefect = new Defect();
newDefect.setAxe(defect.getAxe());
newDefect.setCode(defect.getCode());
newDefect.setCodePrint(defect.getCodePrint());
newDefect.setEndappl(defect.getEndappl());
newDefect.setKwalif1(defect.getKwalif1());
newDefect.setKwalif2(defect.getKwalif2());
newDefect.setLigne(defect.getLigne());
newDefect.setMalus(defect.getMalus());
newDefect.setPosition(defect.getPosition());
newDefect.setRubr1(defect.getRubr1());
newDefect.setRubr2(defect.getRubr2());
newDefect.setSanction(defect.getSanction());
newDefect.setStartappl(defect.getStartappl());
newDefect.setUtilvehic(defect.getUtilvehic());
processLibelles(newDefect, getLibelles(defect));
sessie.save(newDefect);
Full stack trace of any exception that occurs:Code:
11:07:43,074 ERROR JDBCExceptionReporter:46 - Method not supported : IfxSqliConnection:prepareStatement(String,int)
11:07:43,084 ERROR JDBCExceptionReporter:38 - could not insert: [be.goca.general.defects.objects.Defect]
java.sql.SQLException: Method not supported : IfxSqliConnection:prepareStatement(String,int)
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:494)
at com.informix.jdbc.IfxSqliConnect.prepareStatement(IfxSqliConnect.java:5563)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at net.sf.hibernate.util.GetGeneratedKeysHelper.prepareStatement(GetGeneratedKeysHelper.java:39)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:246)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:524)
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:906)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)
at be.goca.general.defects.Synchronizer.synchronize(Synchronizer.java:100)
Name and version of the database you are using: informix 9.4TC2