-->
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.  [ 14 posts ] 
Author Message
 Post subject: Id generator for Informix
PostPosted: Thu Nov 13, 2003 8:59 pm 
Beginner
Beginner

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

My Hibernate mapping works well when I use "native" id generator with MySQL, Interbase, DB2 and SQL Server.

Now, I am trying to make the application runs with Informix, it seems that the "native" id generator doesn't work.


For those who use Hibernate with Informix, can you tell me which id generators you use ?

Thank you very much,

sylvain_2020


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 6:44 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't use Informix, but native should work the same way SQL Server does.
What is the exact error ? Did you change any slightly stuff ahead of driver and dialect ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Id generator for Informix
PostPosted: Fri Nov 14, 2003 10:19 am 
Newbie

Joined: Sun Sep 21, 2003 3:04 pm
Posts: 11
Location: Germany
Hi there,

we use the native id generator with Informix DS 7.?? and there
are no problems with it !?

sylvain_2020 wrote:
Now, I am trying to make the application runs with Informix, it seems that the "native" id generator doesn't work.

For those who use Hibernate with Informix, can you tell me which id generators you use ?

_________________
_______________________
With best regards
S.Homburg
21220 Seevetal / GERMANY


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 11:38 am 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
Hi and thank you for answering.

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();


And I get (without the warning and info messages):
Code:
create table aduana (
   ADUANAID INT8 SERIAL NOT NULL,
   ABREVIACION VARCHAR(20),
   CLAVE VARCHAR(2) not null unique,
   DESCRIPCION VARCHAR(100),
   primary key (ADUANAID)
)
Unsuccessful: A syntax error has occurred



If I execute the same piece of code with <generator class="assigned"/>, it works ... but I would like to make it work with the native id generator.

If you have any suggestions or need more information ...

sylvain_2020


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 11:56 am 
Newbie

Joined: Sun Sep 21, 2003 3:04 pm
Posts: 11
Location: Germany
Code:
create table aduana (
   ADUANAID INT8 SERIAL NOT NULL,
   ABREVIACION VARCHAR(20),
   CLAVE VARCHAR(2) not null unique,
   DESCRIPCION VARCHAR(100),
   primary key (ADUANAID)
)


the creation script is wrong, i think its a bug in
the Informix-Dialect:

Code:
ADUANAID INT8 SERIAL NOT NULL


must be
Code:
ADUANAID SERIAL NOT NULL

or
Code:
ADUANAID SERIAL8 NOT NULL


but a detailed error-message (exception) would be help
more.

_________________
_______________________
With best regards
S.Homburg
21220 Seevetal / GERMANY


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 12:09 pm 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
Here is the exact message I got with native id generator:

Quote:
14-nov-2003 10:03:10 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.0 beta 5
14-nov-2003 10:03:10 net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
14-nov-2003 10:03:10 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
14-nov-2003 10:03:10 net.sf.hibernate.cfg.Environment <clinit>
INFO: JVM proxy support: true
14-nov-2003 10:03:10 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/logis/proyecto/data/Aduana.hbm.xml
14-nov-2003 10:03:10 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: com.logis.proyecto.data.Aduana -> aduana
14-nov-2003 10:03:10 net.sf.hibernate.cfg.Configuration configure
INFO: Configured SessionFactory: null
14-nov-2003 10:03:10 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.InformixDialect
14-nov-2003 10:03:10 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
14-nov-2003 10:03:10 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.informix.jdbc.IfxDriver at URL: jdbc:informix-sqli://192.168.0.89:1527/proyecto3:INFORMIXSERVER=ol_sistemas2;
14-nov-2003 10:03:10 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=XXXX, password=XXXX}
drop table aduana
create table aduana (
ADUANAID INT8 SERIAL NOT NULL,
ABREVIACION VARCHAR(20),
CLAVE VARCHAR(2) not null unique,
DESCRIPCION VARCHAR(100),
primary key (ADUANAID)
)
Unsuccessful: A syntax error has occurred.
14-nov-2003 10:03:11 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: SQL Warning: 0, SQLState: 01I01
14-nov-2003 10:03:11 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: Database has transactions
14-nov-2003 10:03:11 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: SQL Warning: 0, SQLState: 01I04
14-nov-2003 10:03:11 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: Database selected
14-nov-2003 10:03:11 net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:informix-sqli://192.168.0.89:1527/proyecto3:INFORMIXSERVER=ol_sistemas2;
14-nov-2003 10:03:11 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
14-nov-2003 10:03:11 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.InformixDialect
14-nov-2003 10:03:11 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
14-nov-2003 10:03:11 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.informix.jdbc.IfxDriver at URL: jdbc:informix-sqli://192.168.0.89:1527/proyecto3:INFORMIXSERVER=ol_sistemas2;
14-nov-2003 10:03:11 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=XXXX, password=XXXX}
14-nov-2003 10:03:11 net.sf.hibernate.ps.PreparedStatementCache <init>
INFO: prepared statement cache size: 25
14-nov-2003 10:03:11 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Use outer join fetching: false
14-nov-2003 10:03:11 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Use scrollable result sets: true
14-nov-2003 10:03:11 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: echoing all SQL to stdout
14-nov-2003 10:03:11 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: no JDNI name configured
14-nov-2003 10:03:11 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0}


And when I use assigned id generator :

Quote:
14-nov-2003 10:05:32 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.0 beta 5
14-nov-2003 10:05:32 net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
14-nov-2003 10:05:32 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
14-nov-2003 10:05:32 net.sf.hibernate.cfg.Environment <clinit>
INFO: JVM proxy support: true
14-nov-2003 10:05:33 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/logis/proyecto/data/Aduana.hbm.xml
14-nov-2003 10:05:33 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: com.logis.proyecto.data.Aduana -> aduana
14-nov-2003 10:05:33 net.sf.hibernate.cfg.Configuration configure
INFO: Configured SessionFactory: null
14-nov-2003 10:05:33 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.InformixDialect
14-nov-2003 10:05:33 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
14-nov-2003 10:05:33 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.informix.jdbc.IfxDriver at URL: jdbc:informix-sqli://192.168.0.89:1527/proyecto3:INFORMIXSERVER=ol_sistemas2;
14-nov-2003 10:05:33 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=XXXX, password=XXXX}
drop table aduana
Unsuccessful: The specified table (aduana) is not in the database.
create table aduana (
ADUANAID INT8 not null,
ABREVIACION VARCHAR(20),
CLAVE VARCHAR(2) not null unique,
DESCRIPCION VARCHAR(100),
primary key (ADUANAID)
)
14-nov-2003 10:05:33 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: SQL Warning: 0, SQLState: 01I01
14-nov-2003 10:05:33 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: Database has transactions
14-nov-2003 10:05:33 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: SQL Warning: 0, SQLState: 01I04
14-nov-2003 10:05:33 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: Database selected
14-nov-2003 10:05:34 net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:informix-sqli://192.168.0.89:1527/proyecto3:INFORMIXSERVER=ol_sistemas2;
14-nov-2003 10:05:34 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
14-nov-2003 10:05:34 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.InformixDialect
14-nov-2003 10:05:34 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
14-nov-2003 10:05:34 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.informix.jdbc.IfxDriver at URL: jdbc:informix-sqli://192.168.0.89:1527/proyecto3:INFORMIXSERVER=ol_sistemas2;
14-nov-2003 10:05:34 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=XXXX, password=XXXX}
14-nov-2003 10:05:34 net.sf.hibernate.ps.PreparedStatementCache <init>
INFO: prepared statement cache size: 25
14-nov-2003 10:05:34 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Use outer join fetching: false
14-nov-2003 10:05:34 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Use scrollable result sets: true
14-nov-2003 10:05:34 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: echoing all SQL to stdout
YA
14-nov-2003 10:05:34 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: no JDNI name configured
14-nov-2003 10:05:34 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0}


Thanks for you help


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 12:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
http://opensource.atlassian.com/project ... key=HB-414


There is a patch.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 12:54 pm 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
gavin wrote:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-414
There is a patch.


Thanks a lot ... but I am a little bit confused as I am also a beginner in java and I don't what I should do with this patch.

Well, I have downloade the patch informix_patch_to_v2003_II.zip.

I have unzipped it. There 3 files inside :

hibernate-2.0.3\src\net\sf\hibernate\dialect\Dialect.java
hibernate-2.0.3\src\net\sf\hibernate\dialect\Informix9Dialect.java
hibernate-2.0.3\src\net\sf\hibernate\mapping\Table.java

I guess I should "update" hibernate2.jar ... but I don't know how to do.

It is more a java issue than Hibernate issue but I guess you guys are used to it.
Can anybody explain me what do I have to do ?

thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 7:33 pm 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
Ok, I found out how to add the patch to hibernate (ouf!!).

The initial problem is resolved but now, I have new problem that seems to be worse.

Here is my actual hibernate configuration file for informix :

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.Informix9Dialect</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">XXX</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>


And I get the following message :

Quote:
14-nov-2003 17:24:30 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.0.3
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.hsqldb.jdbcDriver, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.query.imports=net.sf.hibernate.test, net.sf.hibernate.eg, hibernate.proxool.pool_alias=pool1, hibernate.connection.username=sa, hibernate.connection.url=jdbc:hsqldb:test, hibernate.show_sql=false, hibernate.connection.password=, hibernate.statement_cache.size=25, hibernate.connection.pool_size=1}
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Environment <clinit>
INFO: using java.io streams to persist binary types
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Environment <clinit>
INFO: JVM proxy support: true
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/logis/proyecto/data/Aduana.hbm.xml
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: com.logis.proyecto.data.Aduana -> aduana
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Configuration configure
INFO: Configured SessionFactory: null
14-nov-2003 17:24:31 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.Informix9Dialect
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
14-nov-2003 17:24:31 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
14-nov-2003 17:24:31 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.informix.jdbc.IfxDriver at URL: jdbc:informix-sqli://192.168.0.89:1527/proyecto3:INFORMIXSERVER=ol_sistemas2;
14-nov-2003 17:24:31 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=XXXX, password=XXXX}
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)
)
Unsuccessful: A syntax error has occurred.
14-nov-2003 17:24:31 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: SQL Warning: 0, SQLState: 01I01
14-nov-2003 17:24:31 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: Database has transactions
14-nov-2003 17:24:31 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: SQL Warning: 0, SQLState: 01I04
14-nov-2003 17:24:31 net.sf.hibernate.util.JDBCExceptionReporter logWarnings
ADVERTENCIA: Database selected
14-nov-2003 17:24:31 net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:informix-sqli://192.168.0.89:1527/proyecto3:INFORMIXSERVER=ol_sistemas2;
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
14-nov-2003 17:24:31 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
14-nov-2003 17:24:32 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
14-nov-2003 17:24:32 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.Informix9Dialect
14-nov-2003 17:24:32 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
14-nov-2003 17:24:32 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.informix.jdbc.IfxDriver at URL: jdbc:informix-sqli://192.168.0.89:1527/proyecto3:INFORMIXSERVER=ol_sistemas2;
14-nov-2003 17:24:32 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=XXXX, password=XXXX}
14-nov-2003 17:24:32 net.sf.hibernate.ps.PreparedStatementCache <init>
INFO: prepared statement cache size: 25
14-nov-2003 17:24:32 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Use outer join fetching: false
14-nov-2003 17:24:32 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Use scrollable result sets: true
14-nov-2003 17:24:32 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: echoing all SQL to stdout
YA
14-nov-2003 17:24:32 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: no JDNI name configured
14-nov-2003 17:24:32 net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0}


I didn't make any change to my mapping file Aduana.xml ... as you can see the type for my fields isn't generated anymore.

Has anybody the same probleme ?

Sylvain


Top
 Profile  
 
 Post subject: How do you apply a patch
PostPosted: Fri Feb 18, 2005 2:50 am 
Newbie

Joined: Fri Feb 18, 2005 2:38 am
Posts: 4
I want to apply the patch at the following location

http://opensource.atlassian.com/project ... key=HB-414

I am hoping this will fix the problem I am having when a map a serial column in Informix to be the Key column.

If this is not the right patch please point me to the right one.

Thanks for the help

SR


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 18, 2005 10:41 am 
Beginner
Beginner

Joined: Tue Sep 02, 2003 3:25 pm
Posts: 21
Location: Kingston Jamaica, West Indies
See if this helps
http://forum.hibernate.org/viewtopic.ph ... 87#2231387


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 20, 2005 10:33 pm 
Newbie

Joined: Fri Feb 18, 2005 2:38 am
Posts: 4
Can you tell me if the problem is fixed 2.1.8.


Top
 Profile  
 
 Post subject: Informix save/SERIAL problem
PostPosted: Tue Jun 07, 2005 2:00 pm 
Newbie

Joined: Tue Jun 07, 2005 1:28 pm
Posts: 1
I have an issue with Informix SERIAL ids as well, but it seems to be a bit different than what is discussed in the threads I have seen so far:

When I create a new object and save it, the insert sql hibernate creates does not include the primary key value in the insert. Even if I manually set the primary key value to zero to trigger the SERIAL auto-increment, the zero value never gets inserted to affect the informix id generator. As a result the insert results in a null value for the primary key (not sure what that says about informix since I have NOT NULL in the table definiton...)
Is there a way to include the primary key value in the insert sql on the initial save call? Or do I have to hack that with a manual series of calls such as
- initial save
-manual update call with id value zero
- one more update call get the generated value into the object's id member ( or worse a manual "select first 1 dbinfo('sqlca.sqlerrd1') from systables" call...)
I sure hope not as that's ugly :(

Thanks for the help.




My config, create table sql, bean and test code:

--------------------------------------------------------------------------------------
config
--------------------------------------------------------------------------------------
<?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>

<class name="org.vaneyk.utilities.hibernate.informix.Prototype" table="table_prototype_hibernate">

<!-- primary key -->
<id name="id" column="id" type="java.lang.Long">
<generator class="native"/>
</id>

<!-- properties -->
<property name="a" column="a" type="integer"/>
<property name="b" column="b" type="integer"/>
<property name="c" column="c" type="integer"/>

<!-- associations -->
<!-- none -->

</class>

<!-- named queries -->
<!-- <query name="">...</query> -->

</hibernate-mapping>

--------------------------------------------------------------------------------------
create table sql
--------------------------------------------------------------------------------------
create table table_prototype_hibernate
(
id serial8 not null,
a integer,
b integer,
c integer
);

--------------------------------------------------------------------------------------
bean method
--------------------------------------------------------------------------------------

package org.vaneyk.utilities.hibernate.informix;

import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;


/** @author Hibernate CodeGenerator */
public class Prototype implements Serializable {

/** identifier field */
private Long id;

/** nullable persistent field */
private Integer a;

/** nullable persistent field */
private Integer b;

/** nullable persistent field */
private Integer c;

/** full constructor */
public Prototype(Integer a, Integer b, Integer c) {

// informix hack for SERIAL8 auto-increment
id = new Long( 0 );

this.a = a;
this.b = b;
this.c = c;
}

/** default constructor */
public Prototype() {
// informix hack for SERIAL8 auto-increment
id = new Long( 0 );
}

public Long getId() {
return this.id;
}

public void setId(Long id) {
this.id = id;
}

public Integer getA() {
return this.a;
}

public void setA(Integer a) {
this.a = a;
}

public Integer getB() {
return this.b;
}

public void setB(Integer b) {
this.b = b;
}

public Integer getC() {
return this.c;
}

public void setC(Integer c) {
this.c = c;
}

public String toString() {
return new ToStringBuilder(this)
.append("id", getId())
.toString();
}

}



--------------------------------------------------------------------------------------
test method
--------------------------------------------------------------------------------------


public void testPrototypeIntegerIntegerInteger()
{
Session session;
try
{
// create prototype
factory.beginTransaction();
session = factory.getSession();
Prototype prototype = new Prototype( a, b, c );
prototype.setId( new Long( 0 ) );
session.save( prototype );
session.flush();

// test
if ( prototype == null )
{
failed( "Contstructor returned null." );
}
else if (
( a.intValue() == prototype.getA().intValue() ) &&
( b.intValue() == prototype.getB().intValue() ) &&
( c.intValue() == prototype.getC().intValue() )
)
{
passed();
}
else
{
failed( "Constructor failed to process parameters correctly." );
}

// clean up
session.delete( prototype );
session.flush();
factory.commitTransaction();
}
catch( HibernateException he )
{
he.printStackTrace( System.err );
failed( he.getLocalizedMessage() );
}
}

-------------------------------------------------------------------------------------
results:
-------------------------------------------------------------------------------------

Hibernate: insert into table_prototype_hibernate (a, b, c) values (?, ?, ?)
Hibernate: select first 1 dbinfo('sqlca.sqlerrd1') from systables
test: pass
Hibernate: delete from table_prototype_hibernate where id=?
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
[edited rest of stack trace out...]
SQL insert, update or delete failed (row not found)
test: fail


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 23, 2006 12:05 pm 
Newbie

Joined: Thu Feb 10, 2005 6:21 am
Posts: 1
Any solution of this problems.

For Informix 7.31 is not working the patch.

It's not possible to pass the'0' to the pk serial columns

Thank you in advance, Goyo.


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