-->
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: HQL syntax for update statment with upper bound on rec num
PostPosted: Mon Jan 07, 2008 10:27 pm 
Regular
Regular

Joined: Fri Oct 01, 2004 2:19 am
Posts: 111
Location: Melbourne, Australia
Hibernate version: 3.2.3

How do I specify, in HQL, an update statement that will update a subset,
bound by some number n, of a matching set of records?

In SQL (and Oracle), I could do something like:

update EVENT_TABLE
set STATE = 'new value'
where rowid in
( select rowid from EVENT_TABLE where STATE = 'some value' and rownum <= 5);

This updates the first 5 rows that match the condition STATE = 'some value' even though there are many more records that actually match.

This uses Oracle's constructs of which rownum is used in Hibernate pagination, but not updates as far as I can see.
Can rowid be used by HQL or does it need to actually be mapped
to an unused property in the mapping file?

Is there a better way of doing this?

_________________
Cheers,

Bonny

please don't forget to rate :)


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.