|
After digging down I saw this Incompatibility of Hibernate 3.1 and JTOpen JDBC drivers for IBM AS/400 http://opensource.atlassian.com/projects/hibernate/browse/HHH-1479 So I downlaod hibernate 3.0.5 and changed the mapping for generator to "increment" and now I am getting this error: (Could not synchronize database state with session). Still unsuccessful in inserting records Hibernate: insert into thoney (name, taste, id) values (?, ?, ?) 11:24:20,242 WARN JDBCExceptionReporter:71 - SQL Error: -7008, SQLState: 55019 11:24:20,258 ERROR JDBCExceptionReporter:72 - [SQL7008] THONEY in RIZWANE not valid for operation. 11:24:20,258 ERROR AbstractFlushingEventListener:277 - Could not synchronize database state with session org.hibernate.exception.GenericJDBCException: could not insert: [ de.laliluna.example.Honey] at org.hibernate.exception.SQLStateConverter.handledNonSpecificException( SQLStateConverter.java:82) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70) at org.hibernate.exception.JDBCExceptionHelper.convert( JDBCExceptionHelper.java:43) at org.hibernate.persister.entity.BasicEntityPersister.insert( BasicEntityPersister.java:1869) at org.hibernate.persister.entity.BasicEntityPersister.insert( BasicEntityPersister.java:2200) at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46) On 1/8/07, Rizwan Ahamed <rahamed@xxxxxxxxx> wrote:
Hi I am tying to use hibernate with iSeries and i am not able to insert records to the file but I am able to query . I am trying to use the 'sequence' in generator element while mapping. here is my hibernate.cfg.xml <session-factory> <property name="connection.username">rizwane</property> <property name="connection.url">jdbc:as400://xxx.xxx.xx.x/rizwane;translate binary=true</property> <property name="dialect">org.hibernate.dialect.DB2400Dialect</property> <property name="myeclipse.connection.profile">AS400</property> <property name="connection.password">x</property> <property name="connection.driver_class"> com.ibm.as400.access.AS400JDBCDriver</property> <property name="transaction.factory_class"> org.hibernate.transaction.JDBCTransactionFactory</property> <property name="current_session_context_class">thread</property> <!-- this will show us all sql statements --> <property name="hibernate.show_sql">true</property> <!-- this will create the database tables for us --> <!-- <property name="hibernate.hbm2ddl.auto">create</property>--> <mapping resource="Honey.hbm.xml" /> here is my mapping <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" " http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="rizwan.in.example"> <class name="Honey" table="thoney" > <id name="id" type="long" column="id"> <generator class="sequence"> <param name="sequence">honey_id_seq</param> </generator> </id> <property name="name" type="string" column="name" ></property> <property name="taste" type="string" column="taste" ></property> </class> </hibernate-mapping> and when i run the example here is the error i am getting for insert (could not get next sequence value ) 15:56:42,501 DEBUG SQL:346 - values nextval for honey_id_seq Hibernate: values nextval for honey_id_seq 15:56:42,736 WARN JDBCExceptionReporter:71 - SQL Error: -29, SQLState: 42601 15:56:42,736 ERROR JDBCExceptionReporter:72 - [SQL0029] INTO clause missing from embedded statement. org.hibernate.exception.SQLGrammarException: could not get next sequence value at org.hibernate.exception.SQLStateConverter.convert( SQLStateConverter.java:67) at org.hibernate.exception.JDBCExceptionHelper.convert( JDBCExceptionHelper.java:43) at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:96) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId( AbstractSaveEventListener.java:91) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId (DefaultSaveOrUpdateEventListener.java:186) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId (DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient (DefaultSaveOrUpdateEventListener.java:175) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate( DefaultSaveEventListener.java:27) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate (DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:530) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:51 at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514) at de.laliluna.example.TestExample.createHoney(TestExample.java:83) at de.laliluna.example.TestExample.main(TestExample.java:33) Caused by: java.sql.SQLException: [SQL0029] INTO clause missing from embedded statement. at com.ibm.as400.access.JDError.throwSQLException(JDError.java:650) at com.ibm.as400.access.JDError.throwSQLException(JDError.java:621) at com.ibm.as400.access.AS400JDBCStatement.commonPrepare( AS400JDBCStatement.java:1506) at com.ibm.as400.access.AS400JDBCPreparedStatement.<init>( AS400JDBCPreparedStatement.java:185) at com.ibm.as400.access.AS400JDBCConnection.prepareStatement( AS400JDBCConnection.java:1903) at com.ibm.as400.access.AS400JDBCConnection.prepareStatement( AS400JDBCConnection.java:1726) at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement( AbstractBatcher.java:442) at org.hibernate.jdbc.AbstractBatcher.prepareSelectStatement( AbstractBatcher.java:99) at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:73) ... 11 more 15:56:42,752 DEBUG TestExample:36 - Honey: null Name: forest honey Taste: very sweet 15:56:43,081 DEBUG SQL:346 - select honey0_.id as id0_, honey0_.name as name0_, honey0_.taste as taste0_ from thoney honey0_ Hibernate: select honey0_.id as id0_, honey0_.name as name0_, honey0_.taste as taste0_ from thoney honey0_ 15:56:43,333 DEBUG TestExample:53 - Honey: 1 Name: FSDGFDGD Taste: SDFSDFSD 15:56:43,333 DEBUG TestExample:53 - Honey: 2 Name: DFGFD The same thing works well on MySQL database. For iSeries I am able to list the data , the problem is in inserting the record, i tried 'native' for generator element and all options. I even deleted the auto created file and created the file manually in the iSeries and still the same error: Any help will be appreciated I was going through David Morris example alsoe ( http://www.itjungle.com/fhg/fhg030304-story01.html) but with no luck. May be he could help here :-) Thanks Rizwan http://www.rizwan.in -- Rizwan
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.