-->
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.  [ 7 posts ] 
Author Message
 Post subject: Exception from Sequence Generator
PostPosted: Mon Mar 06, 2006 5:17 am 
Newbie

Joined: Thu Jan 19, 2006 3:40 am
Posts: 8
Hi all,

I have a problem on using Hibernate 3.1 with HSQLDB 1.8. I get the following exception:


09:27:30,255 DEBUG SQL:346 - select next value for hibernate_sequence from dual_hibernate_sequence
09:27:30,255 WARN JDBCExceptionReporter:71 - SQL Error: -191, SQLState: S0002
09:27:30,265 ERROR JDBCExceptionReporter:72 - Sequence not found: HIBERNATE_SEQUENCE in statement [select next value for hibernate_sequence from dual_hibernate_sequence]
09:27:30,275 ERROR AbstractFlushingEventListener:299 - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: could not get next sequence value
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:96)
at org.hibernate.collection.PersistentIdentifierBag.preInsert(PersistentIdentifierBag.java:298)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1010)


the mapping file I use is:

<hibernate-mapping>
<class name="LogistischesTeil" schema="ABC" table="LOGISTISCHESTEIL">
<id column="ID" name="id" type="int"/>
<property column="SACHNR" name="SNR" type="integer" not-null="true" />

<idbag name="colourSpecificLogistischeTeile" schema="ABC" table="FARBMAPPING" >
<collection-id column="id" type="int">
<generator class="sequence"/>
</collection-id>

<key column="lt_id_farbneutral"/>
<many-to-many column="lt_id_farbspezifisch" class="LogistischesTeil" fetch="join"/>
</idbag>
</class>
</hibernate-mapping>

What is my mistake? Thanks for help,
Philipp

_________________
Philipp Seuring


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 5:32 am 
Regular
Regular

Joined: Tue Nov 29, 2005 12:31 pm
Posts: 75
Hi,

try using

<id name="id" column="ID" type="java.lang.Long">
<generator class="increment"/>
</id>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 6:08 am 
Newbie

Joined: Thu Jan 19, 2006 3:40 am
Posts: 8
Hi,

Thanks a lot for your reply.

Why did you tell me to use id instead of collection-id. This is not possible inside the idbag tag. For the moment I tried:

<idbag name="colourSpecificLogistischeTeile" schema="KIS" table="FARBMAPPING" >
<collection-id column="id" type="int">
<generator class="increment"/>
</collection-id>

<key column="lt_id_farbneutral"/>
<many-to-many column="lt_id_farbspezifisch" class="LogistischesTeil" fetch="join"/>
</idbag>

And I get a some kind of similar error message. I am wondering why the exception tells me that he can not find the FARBMAPPING table. It is there for sure.

The new exception:


11:01:37,329 DEBUG SQL:346 - select max(id) from FARBMAPPING
11:01:37,329 WARN JDBCExceptionReporter:71 - SQL Error: -22, SQLState: S0002
11:01:37,329 ERROR JDBCExceptionReporter:72 - Table not found in statement [select max(id) from FARBMAPPING]
11:01:37,339 ERROR AbstractFlushingEventListener:299 - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:107)
at org.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:44)


Regards Philipp

_________________
Philipp Seuring


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 6:15 am 
Newbie

Joined: Thu Jan 19, 2006 3:40 am
Posts: 8
Hi All,

why is he ignoring the schema information. Other SQLs look like:

insert into KIS.LOGISTISCHESTEIL (SACHNR,....

but the one which does not work looks like:

select max(ID) from FARBMAPPING

I attended:

select max(ID) from KIS.FARBMAPPING

Am I wrong?

Regards Philipp

_________________
Philipp Seuring


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 14, 2006 1:20 pm 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
I had the same problem.

I tried to track it, and I've noticed that the schema parameter in class IncrementGenerator is null, if the schema parameter was specified in the hbm descriptor.

In class SimpleValue, line 108, I've noticed this comment:
Code:
      //if the hibernate-mapping did not specify a schema/catalog, use the defaults
      //specified by properties - but note that if the schema/catalog were specified
      //in hibernate-mapping, or as params, they will already be initialized and
      //will override the values set here (they are in identifierGeneratorProperties)


I can't find where the schema parameter is set, can someone who knows the source code better then me shed some light on this ?

_________________
--
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 10:39 am 
Newbie

Joined: Thu Jan 19, 2006 3:40 am
Posts: 8
Hi marco-p,

Thanks for tracking the problem down to this point. I solved the problem by writing a simple own Generator which is sufficient for my problem. It is a simple integer value I increment on every call.

Philipp

_________________
Philipp Seuring


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 10:57 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
Hi Philipp,
I'm glad it helped. This bug has been reported in Jira as bug 1087 but I don't think it'll be corrected.

Bye

_________________
--
Marco


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