-->
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.  [ 3 posts ] 
Author Message
 Post subject: IdBag and db2 Identity generator
PostPosted: Tue Feb 05, 2008 12:41 pm 
Newbie

Joined: Tue Feb 05, 2008 11:16 am
Posts: 5
I'm having an issue when trying to save a collection in an <idbag> under Hibernate with DB2. The error that results is a class cast exception, and it appears to result from the POST_INSERT_INDICATOR being used as the identifier instead of the actual long identifier. This occurs in LongType (ln 42) when trying to set the long value, and the value is actually the "POST_INSERT_INDICATOR" string.

I've read that you cannot use <generator class="native"/> for idbags:
http://www.hibernate.org/hib_docs/reference/en/html/collections.html#collections-idbag
I figured identity would work since I'm using DB2.


Hibernate version:
3.1.2

Name and version of the database you are using:
DB2 Version 9

Mapping documents:
Here's the idbag in Claim.hbm.xml:
Code:
<idbag name="standardTextSpecifications"
           table="CLAIM_STD_TEXT_REL"
           lazy="true" cascade="save-update">
    <collection-id column="CLM_STD_TXT_ID" type="long">
        <generator class="identity"/>
    </collection-id>
    <key column="CLM_ID"/>
    <many-to-many column="STD_TXT_SPEC_ID"
        class="StandardTextSpecification" fetch="join"/>
</idbag>


Full stack trace of any exception that occurs:
Here's the stack trace of the ClassCastException. A Claim object is trying to be saved.:
java.lang.ClassCastException
at org.hibernate.type.LongType.set(LongType.java:42)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65)
at org.hibernate.persister.collection.AbstractCollectionPersister.writeIdentifier(AbstractCollectionPersister.java:749)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1031)
at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)


The generated SQL:
Code:
Hibernate: insert into CLAIM_STD_TEXT_REL (CLM_ID, CLM_STD_TXT_ID, STD_TXT_SPEC_ID) values (?, ?, ?)


Debug level Hibernate log excerpt:
Code:
org.hibernate.type.LongType    - INFO [main] - could not bind value 'POST_INSERT_INDICATOR' to parameter: 2; null


Here's the table definition of the join table, although it's not very suprising:
CREATE TABLE CLAIM_STD_TEXT_REL
(
CLM_STD_TXT_ID INTEGER NOT NULL
GENERATED ALWAYS
AS IDENTITY (
START WITH 1,
INCREMENT BY 1,
NO CACHE,
NO CYCLE
),
CLM_ID INTEGER NOT NULL ,
STD_TXT_SPEC_ID INTEGER NOT NULL
)
;

If anyone can offer any help I'd greatly appreciate it. For now I'm stuck mapping a persistent object for many of these similar join tables, and it really uglifies my data model. IdBag is created just for these situations and I'd like to use it.
Thanks,
Frank


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 05, 2008 4:42 pm 
Newbie

Joined: Tue Feb 05, 2008 11:16 am
Posts: 5
It appears this is related http://forum.hibernate.org/viewtopic.php?t=945855&highlight=&sid=1c95bc1d54b0286b8cbae1a85e9e6bfa.
The same issue occurs with idbags using composite elements, and with MySQL.

Apparently it's also been around for a long time, 2005? I can't be the first person to run into this.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Thu Jun 24, 2010 4:45 pm 
Newbie

Joined: Thu Jun 17, 2010 12:31 pm
Posts: 4
fkearney wrote:
It appears this is related http://forum.hibernate.org/viewtopic.php?t=945855&highlight=&sid=1c95bc1d54b0286b8cbae1a85e9e6bfa.
The same issue occurs with idbags using composite elements, and with MySQL.

Apparently it's also been around for a long time, 2005? I can't be the first person to run into this.


Old thread, but an old problem. I also am having this problem with the identity generator strategy on DB2. Is there any resolution to this problem?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.