-->
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.  [ 5 posts ] 
Author Message
 Post subject: Still having problem with Informix dialect ...
PostPosted: Fri Nov 28, 2003 1:00 pm 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
Hi,

I am using Informix Dynamic Server for Windows Version: 9.4 with the IBM Informix JDBC Driver 2.21.JC5.

Here is the XML file to map a simple class Aduana.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
   <class name="com.logis.proyecto.data.Aduana" table="aduana">
      <id name="id" type="long" column="ADUANAID" unsaved-value="0">
         <generator class="native"/>
      </id>   

      <property name="abreviacion" type="string">
         <column name="ABREVIACION" length ="20"/>
      </property>

      <property name="clave" >
         <column name="CLAVE" unique = "true" not-null="true" length="2"/>
      </property>

      <property name="descripcion" >
         <column name="DESCRIPCION" length="100"/>
      </property>

    </class>
</hibernate-mapping>


Here is my XML configuration file for Informix (informix.cfg.xml):
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>

    <session-factory>
   <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
   <property name="hibernate.dialect">net.sf.hibernate.dialect.InformixDialect</property>
   <property name="connection.driver_class">com.informix.jdbc.IfxDriver</property>
   <property name="connection.url">jdbc:informix-sqli://192.168.0.89:1527/proyecto3:INFORMIXSERVER=ol_sistemas2;</property>
   <property name="connection.username">XXXX</property>
   <property name="connection.password">XXXX</property>
   <property name="connection.pool_size">1</property>
   <property name="statement_cache.size">25</property>
   <property name="proxool.pool_alias">pool1</property>
   <property name="hibernate.show_sql">true</property>
   <property name="jdbc.batch_size">0</property>
   <property name="jdbc.use_streams_for_binary">true</property>

   <mapping resource="com/logis/proyecto/data/Aduana.hbm.xml" />
   </session-factory>

</hibernate-configuration>


I export my tables with this piece of code :
Code:
      String filePath = new File("src/informix.cfg.xml").getAbsolutePath();
       
      File file = new File(filePath);       
      Configuration cfg = new Configuration().configure(file);
      new SchemaExport(cfg).create(true, true);
      cfg.buildSessionFactory();


As Gavin suggested me, I am using the following patch to correct the problem of native id generator :
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-414

The SQL generated is :

Code:
....
drop table aduana
Unsuccessful: The specified table (aduana) is not in the database.
create table aduana (
   ADUANAID  SERIAL8 NOT NULL,
   ABREVIACION ,
   CLAVE  not null unique,
   DESCRIPCION ,
   primary key (ADUANAID)
)
28-nov-2003 10:45:31 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: SQL Warning: 0, SQLState: 01I01
28-nov-2003 10:45:31 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: Database has transactions
28-nov-2003 10:45:31 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: SQL Warning: 0, SQLState: 01I04
28-nov-2003 10:45:31 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
Unsuccessful: A syntax error has occurred.
....


Obviously, the type of my fields are not generated exept for the id !

Does anybody had the same problem ?

Any suggestion to fix it ?

Sylvain


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 28, 2003 7:56 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I presume that the patch is either wrong, or that you only applied part of it.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 29, 2003 1:21 pm 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
There are 3 files in this patch, I added all of them in the right directory (I did it several times!) ... but I still have the same problem!

I really need to make my application work with informix but I don't know what to do.

Does anybody manager to use hibernate with Informix and "native id generator" ?

Sylvain


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 29, 2003 9:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Now, my understanding is that you only had a problem with the pk column type that was produced by SchemaExport. I wouldn't have thought that this was a massive showstopper! Surely you can do a text search/replace on the generated DDL script? Just as a temporary workaround till someone who is a able to test on Informix is able to look into this...


Top
 Profile  
 
 Post subject: Hibernate bug with Informix 9.4 serial8 datatype
PostPosted: Fri Feb 18, 2005 10:35 am 
Beginner
Beginner

Joined: Tue Sep 02, 2003 3:25 pm
Posts: 21
Location: Kingston Jamaica, West Indies
Hibernate verison: 2.1.7c
Database product name : Informix Dynamic Server
Database product version : 9.40.UC3
JDBC driver name : IBM Informix JDBC Driver for IBM Informix Dynamic Server
JDBC driver version : 2.21.JC3
App Server: Websphere 5.1


If in your mapping file, using the native id generator .

When an object is saved, the implementation to return the generated keys i.e
Informix9Dialect.getIdentitySelectString() does not work for serial8 only serial.

What needs to be done is this
Code:
   /**
    * @see net.sf.hibernate.dialect.Dialect#getIdentitySelectString()
    */
   public String getIdentitySelectString() throws MappingException {
      return "select first 1 case when dbinfo('serial8') = 0 then " +
         "(select dbinfo('sqlca.sqlerrd1') from systables where tabid = 1 ) " +
         "else (select dbinfo('serial8') from systables where tabid = 1 )+0 " +
         "end from systables";
   }


To obtain the value of the last SERIAL value that is inserted into a table, use the 'sqlca.sqlerrd1' option of DBINFO().

select dbinfo('serial8') from systables where tabid = 1 is the documented way to get the serial8 key value to pass it on to the child association in hibernate.
The original way return 0 causing a number of issues to occur;


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.