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