-->
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: HXTT Text trial : SEQUENCE-generated ID always the same
PostPosted: Fri Mar 07, 2008 6:12 am 
Newbie

Joined: Fri Mar 07, 2008 6:01 am
Posts: 7
Location: Brussels, BELGIUM
Hi all,

I have to save objects to flat files (CSV) for a gigantic import in a database (test data injection).
As Hibernates' documentation asserts it is possible with HXTT's driver and dialect, I am trying (I already have all the HBM files, so it is easier for me to do it like that).

If I try a basic test, I get an error.
I can do a "create table" : my file is created.
But when I try to instantiate my object and to save it
Code:
Period p = new Period();
p.setBegin(GregorianCalendar.getInstance());
p.setEnd(GregorianCalendar.getInstance());
       
getHibernateTemplate().save(p);

Hibernate complains :
Code:
insert into PERIOD (P_BEGIN, P_END, ID) values (?, ?, ?)
0          [main      ] ERROR org.hibernate.util.JDBCExceptionReporter  - java.sql.SQLException: Can't find column: P_BEGIN in table PERIOD
0          [main      ] ERROR org.hibernate.util.JDBCExceptionReporter  - Can't find column: P_BEGIN in table PERIOD
0          [main      ] ERROR org.hibernate.event.def.AbstractFlushingEventListener  - Could not synchronize database state with session

...of course... the CSV file is empty...

Has anyone any idea?

Thanks in advance![/code]


Last edited by Elnourso on Fri Mar 07, 2008 9:14 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: SEQUENCE-generated ID always the same
PostPosted: Fri Mar 07, 2008 9:12 am 
Newbie

Joined: Fri Mar 07, 2008 6:01 am
Posts: 7
Location: Brussels, BELGIUM
OK, I reply partly to my question :
I needed to create using ?_CSV_HEADER=true at the end of the connection url...
BUT... ;)
Quote:
Hibernate can add only 1 record. At the second, it throws :
Hibernate: select nextval('S_PE')
Hibernate: insert into PERIOD (P_BEGIN, P_END, ID) values (?, ?, ?)
Hibernate: select nextval('S_PE')
Hibernate: insert into PERIOD (P_BEGIN, P_END, ID) values (?, ?, ?)
0 [main ] ERROR org.hibernate.util.JDBCExceptionReporter - java.sql.SQLException: Failed to insert a new record into table PERIOD! For more information, please use SQLException.getNextException().
0 [main ] ERROR org.hibernate.util.JDBCExceptionReporter - Failed to insert a new record into table PERIOD! For more information, please use SQLException.getNextException().
0 [main ] ERROR org.hibernate.util.JDBCExceptionReporter - Failed to insert a duplicate key for conflict with record 1
15 [main ] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session


I do a loop that adds Period objects and saves them. After a debug, I found out that HXTT 's classes generates 2 times the same id out of a sequence (used in the HBM file)
Code:
CREATE S "S_PE"  MINPE"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 401 CACHE 200 NOORDER  NOCYCLE ;

The field (in HBM)
Code:
<id name="id" type="long">
         <column name="ID" precision="18" scale="0" not-null="true" />
         <generator class="sequence">
            <param name="sequence">S_PE</param>
         </generator>
      </id>

HXTT always generates an ID "5784066817803503950"...

Big Bug? It qhould begin with ID="401" but does not...

Thanx


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.