-->
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.  [ 2 posts ] 
Author Message
 Post subject: Informix ID Generator class and Informix 7 or 5 DataTypes
PostPosted: Thu Sep 29, 2005 1:14 pm 
Newbie

Joined: Thu Sep 29, 2005 12:23 pm
Posts: 1
Location: Argentina
Hi !
The informix dialect maps an ID field with generator class native, increment, identity o sequence to serial8 or int8 Informix DataTypes, but this are only for Informix 9 and i need use it in Informix 7 and even 5
Check at the column EVENT_ID of the Mapping documents and the SQL generated...

The correct DataType should be serial or int (not serial8 or int8)

Please some help! Thanks

Hibernate version: 3.0

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native" />
</id>
<property name="date" type="timestamp" column="EVENT_DATE" />
<property name="title" />
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);
session.save(theEvent);
tx.commit();
HibernateUtil.closeSession();

Full stack trace of any exception that occurs:
[java] 14:06:10,515 DEBUG SchemaExport:143 - drop table EVENTS
[java] 14:06:10,562 DEBUG SchemaExport:149 - Unsuccessful: drop table EVENTS
[java] 14:06:10,562 DEBUG SchemaExport:150 - The specified table (events) is not in the database.
[java] 14:06:10,562 DEBUG SchemaExport:161 - create table EVENTS (
[java] EVENT_ID serial8 not null,
[java] EVENT_DATE datetime year to fraction(5),
[java] title varchar(255),
[java] primary key (EVENT_ID)
[java] )
[java] 14:06:10,578 ERROR SchemaExport:167 - Unsuccessful: create table EVENTS (EVENT_ID serial8 not null, EVENT_DATE datetime year to fraction(5), title varchar(255), primary key (EVENT_ID))
[java] 14:06:10,578 ERROR SchemaExport:168 - A syntax error has occurred.
[java] 14:06:10,578 INFO SchemaExport:173 - schema export complete
[java] 14:06:10,578 WARN JDBCExceptionReporter:48 - SQL Warning: 0, SQLState: 01I01
[java] 14:06:10,593 WARN JDBCExceptionReporter:49 - Database has transactions
[java] 14:06:10,593 WARN JDBCExceptionReporter:48 - SQL Warning: 0, SQLState: 01I04
[java] 14:06:10,593 WARN JDBCExceptionReporter:49 - Database selected
[java] 14:06:10,609 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:informix-sqli://desa:5555/basurero:INFORMIXSERVER=impedb
[java] 14:06:10,625 INFO SessionFactoryImpl:379 - Checking 0 named queries
[java] 14:06:10,750 DEBUG JDBCTransaction:46 - begin
[java] 14:06:10,765 DEBUG ConnectionManager:296 - opening JDBC connection
[java] 14:06:10,765 DEBUG JDBCTransaction:50 - current autocommit status: false
[java] 14:06:10,796 DEBUG AbstractBatcher:290 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[java] 14:06:10,796 DEBUG SQL:324 - insert into EVENTS (EVENT_DATE, title) values (?, ?)
[java] Hibernate: insert into EVENTS (EVENT_DATE, title) values (?, ?)
[java] 14:06:10,796 DEBUG AbstractBatcher:378 - preparing statement
[java] 14:06:10,828 WARN JDBCExceptionReporter:71 - SQL Error: -206, SQLState: 42000
[java] 14:06:10,828 ERROR JDBCExceptionReporter:72 - The specified table (events) is not in the database.
[java] 14:06:10,828 WARN JDBCExceptionReporter:71 - SQL Error: -111, SQLState: IX000
[java] 14:06:10,828 ERROR JDBCExceptionReporter:72 - ISAM error: no record found.
[java] 14:06:10,828 WARN JDBCExceptionReporter:71 - SQL Error: -206, SQLState: 42000
[java] 14:06:10,828 ERROR JDBCExceptionReporter:72 - The specified table (events) is not in the database.
[java] 14:06:10,828 WARN JDBCExceptionReporter:71 - SQL Error: -111, SQLState: IX000
[java] 14:06:10,828 ERROR JDBCExceptionReporter:72 - ISAM error: no record found.
[java] Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [Event]
[java] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
[java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
[java] at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1777)
[java] at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2178)
[java] at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:34)
[java] at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
[java] at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:240)
[java] at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
[java] at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:95)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
[java] at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
[java] at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
[java] at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
[java] at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
[java] at EventManager.createAndStoreEvent(Unknown Source)
[java] at EventManager.main(Unknown Source)
[java] Caused by: java.sql.SQLException: The specified table (events) is not in the database.
[java] at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3105)
[java] at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3419)
[java] at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2282)
[java] at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2202)
[java] at com.informix.jdbc.IfxSqli.executePrepare(IfxSqli.java:1093)
[java] at com.informix.jdbc.IfxResultSet.executePrepare(IfxResultSet.java:189)
[java] at com.informix.jdbc.IfxPreparedStatement.setupExecutePrepare(IfxPreparedStatement.java:193)
[java] at com.informix.jdbc.IfxPreparedStatement.<init>(IfxPreparedStatement.java:171)
[java] at com.informix.jdbc.IfxSqliConnect.prepareStatement(IfxSqliConnect.java:1964)
[java] at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:396)
[java] at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:76)
[java] at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1739)
[java] ... 15 more
[java] Java Result: 1

Name and version of the database you are using:
[java] 14:06:08,859 INFO SettingsFactory:77 - RDBMS: INFORMIX-OnLine, version: 7.31.UC7
[java] 14:06:08,875 INFO SettingsFactory:78 - JDBC driver: IBM Informix JDBC Driver for IBM Informix Dynamic Server, version: 2.21.JC6
[java] 14:06:08,906 INFO Dialect:92 - Using dialect: org.hibernate.dialect.InformixDialect

The generated SQL (show_sql=true):
[java] 14:06:10,562 DEBUG SchemaExport:161 - create table EVENTS (
[java] EVENT_ID serial8 not null,
[java] EVENT_DATE datetime year to fraction(5),
[java] title varchar(255),
[java] primary key (EVENT_ID)
[java] )
[java] 14:06:10,578 ERROR SchemaExport:167 - Unsuccessful: create table EVENTS (EVENT_ID serial8 not null, EVENT_DATE datetime year to fraction(5), title varchar(255), primary key (EVENT_ID))
[java] 14:06:10,578 ERROR SchemaExport:168 - A syntax error has occurred.

Debug level Hibernate log excerpt:

_________________
A.U.S. Enrique Ferreyra
Red Megatone
Santa Fe - Argentina


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 7:28 am 
Newbie

Joined: Fri Dec 23, 2005 1:18 pm
Posts: 7
Enrique, uso la misma versión de Informix, pero con Hibernate 2.1.8.
Probé los generadores native, identity, increment, y me funcionaron bien, con tablas que usan campos serial como pk.
(Tengo otro problema, que posteé más arriba, pero con los generadores, nunca)

Asumo que al hacer un drop y después el create, solamente es para reinicializar los índices a 0, debido a la falta del truncate.
Por lo que estoy leyendo, hay un error de sintáxis en el create table...
También, al querer hacer el insert, deja el cálculo del serial a la base, ya que el insert especifica solamente las otras dos columnas con sus respectivos valores, pero no le asigna nada a la columna serial. Así que desestimo que al momento del insert, haya algún problema, más allá que el query pinche porque la tabla nunca fue creada...

Si seguís pensando que es el problema del tipo de dato serial y serial8
quizás necesites cambiar la clase dialecto de informix.
Nunca en mi proyecto leí, que hibernate haya hecho referencia al tipo serial 8. Podés cambiar a hibernate 2x, solamente para hacer pruebas?

Un abrazo

Jorge Toselli
Rosario - Argentina


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