-->
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.  [ 1 post ] 
Author Message
 Post subject: BUG?Hibernate bulk operation does not work with composite id
PostPosted: Wed Oct 03, 2007 10:49 am 
Newbie

Joined: Wed May 02, 2007 11:53 am
Posts: 3
Hi, All:

I tried to do some bulk operations without using the cache. But I found very simple updates cannot be handled by Hibernate 3 if the composite ID is used.

Below is my mapping file for the table:
<hibernate-mapping>

<class name="Entityoid" table="ENTITYOID" >

[b] <composite-id name="comp_id" class="EntityoidPK">
<key-property name="idType" column="ID_TYPE" type="java.lang.String" length="16" />
<key-property name="entityoid" column="ENTITYOID" type="java.lang.Long" length="10" />
</composite-id> [/b]

<property name="description" type="java.lang.String" column="DESCRIPTION" length="512" />
...
</class>
</hibernate-mapping>

And here's my simple update:
... //create session
Transaction trans = session.beginTransaction();
try{
String hqlUpdate = "update Entityoid set description=:newDesc " +
"where comp_id.idType= :type and" +
" comp_id.entityoid = :entityOID" ;
int updatedEntities =
session.createQuery( hqlUpdate)
.setString("newDesc", newDesc)
.setString("type", type)
.setLong("entityOID", entityOID)
.executeUpdate();

trans.commit();
}

The database I used is Oracle10g. And here's what I got:

Hibernate: update ENTITYOID set DESCRIPTION=? where entit0_.ID_TYPE=? and entit0_.ENTITYOID=?
- SQL Error: 904, SQLState: 42000
- ORA-00904: "ENTIT0_"."ENTITYOID": invalid identifier

org.hibernate.exception.SQLGrammarException: could not execute update query

It seems Hibernate translates comp_id incorrectly to get this error. If I don't use any comp_id field in the update, then it runs fine.

Is this a Hibernate bug?

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.