-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: Informix jdbc throws "Method not supported"
PostPosted: Thu Aug 12, 2004 5:26 am 
Newbie

Joined: Fri Apr 23, 2004 3:35 am
Posts: 8
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 5:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Try setting hibernate.jdbc.use_getGeneratedKeys=false in your config


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 5:36 am 
Newbie

Joined: Fri Apr 23, 2004 3:35 am
Posts: 8
Well, ok... but then he throws the following message.

Code:
11:32:18,659 ERROR JDBCExceptionReporter:46 - Primary key on table (defects) has a field with a null key value.
11:32:18,669 ERROR JDBCExceptionReporter:46 - Primary key on table (defects) has a field with a null key value.
11:32:18,689 ERROR JDBCExceptionReporter:38 - could not insert: [be.goca.general.defects.objects.Defect]
java.sql.SQLException: Primary key on table (defects) has a field with a null key value.
   at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3082)
   at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3396)
   at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2259)
   at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2179)
   at com.informix.jdbc.IfxSqli.executeCommand(IfxSqli.java:721)
   at com.informix.jdbc.IfxResultSet.executeUpdate(IfxResultSet.java:305)
   at com.informix.jdbc.IfxStatement.executeUpdateImpl(IfxStatement.java:882)
   at com.informix.jdbc.IfxPreparedStatement.executeUpdate(IfxPreparedStatement.java:281)
   at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:527)
   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:99)
   at be.goca.general.defects.DefectViewSynchronizer.start(DefectViewSynchronizer.java:49)
   at be.goca.general.defects.DefectViewSynchronizer.main(DefectViewSynchronizer.java:60)



Apparently Hibernate no longer retrieves the generated key automatically. How can I force Hibernate to retrieve the primary key before he saves the collections ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 8:26 am 
Newbie

Joined: Fri Apr 23, 2004 3:35 am
Posts: 8
I tried the id generator increment, the rows are being inserted but the link from defects to the "child-tables" is missing. ???!!!!

AAaargh, stupid informix JDBC driver. Does anybody have an alternative?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 10:17 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
A guy post a new Informix dialect on JIRA today, have a look and give us feedbacks

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 2:39 am 
Newbie

Joined: Fri Apr 23, 2004 3:35 am
Posts: 8
Thanx, will test it. I will post the results soon.


Top
 Profile  
 
 Post subject: tested it, didn't work
PostPosted: Wed Aug 25, 2004 8:39 am 
Newbie

Joined: Fri Apr 23, 2004 3:35 am
Posts: 8
In fact these were changes to the informix dialect, but it didn't solve my problem.

In fact the problem is caused by the informix JDBC driver that doesn't support the

Code:
prepareStatement(String sql, int autoGeneratedKeys)


function. Does anybody know a workaround? or a free driver that does support getGeneratedKeys?

Thanx,


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 25, 2004 8:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Perhaps you need to

(1) still disable getGeneratedKeys()
(2) override Dialect.getIdentityInsertString()


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 25, 2004 9:04 am 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
Wesley wrote:
I tried the id generator increment, the rows are being inserted but the link from defects to the "child-tables" is missing. ???!!!!


Hello Wesley... just a small hint...
Are you sure your 'defnatures' set shouldn't be a many-to-many to 'Defnature' (with an intermediate table between twe two ?).
Have the feeling your Defnature entities may be shared by multiple Defects.

I may be wrong - the answer depends on what you actually want to model - but this may explain your surprise may the 'link to child tables' are gone...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 25, 2004 9:57 am 
Newbie

Joined: Fri Apr 23, 2004 3:35 am
Posts: 8
Well not exactly, the model seems to be right. For the moment I have used a workaround. I have set the id generater for "defect" to assigned, and I set the id manualy. This works for this procedure but is unusefull in a real time application.

Soon we will develop an application and it would be very usefull if this issue could be resolved...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 25, 2004 9:59 am 
Newbie

Joined: Fri Apr 23, 2004 3:35 am
Posts: 8
I resolved the issue where the links to the defects table weren't inserted. For testing purposes I had set invert to true. :-)

Sorry,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.