-->
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: update setMaxResults
PostPosted: Tue Sep 04, 2012 9:30 am 
Newbie

Joined: Tue Sep 04, 2012 9:26 am
Posts: 2
I hope it is the appropriate section, I have a problem with this code

Transaction transaction = session.beginTransaction();
Query query = session.createQuery("update database set floop= :ctrl1" +" where ctrl= :ctrl2 ").setMaxResults(2);
// query.setMaxResults(2);
query.setParameter("ctrl1",3);
query.setParameter("ctrl2", 5);

I ask through setMaxResults (2) to do the update only on the first two and he makes the update of all records as I do what is wrong?? thanks for any help


Top
 Profile  
 
 Post subject: Re: update setMaxResults
PostPosted: Wed Sep 05, 2012 2:47 am 
Newbie

Joined: Wed Sep 21, 2011 2:20 pm
Posts: 16
mgaforever wrote:
I hope it is the appropriate section

probably not ;-)

mgaforever wrote:
I ask through setMaxResults (2) to do the update only on the first two and he makes the update of all records as I do what is wrong?? thanks for any help


Code:
   /**
    * Set the maximum number of rows to retrieve. If not set,
    * there is no limit to the number of rows retrieved.
    * @param maxResults the maximum number of rows
    */
   public Query setMaxResults(int maxResults);


as it is written in the description, setMaxResults just limits the number of rows you retrieve with a "select" statement.


Top
 Profile  
 
 Post subject: Re: update setMaxResults
PostPosted: Wed Sep 05, 2012 3:26 am 
Newbie

Joined: Tue Sep 04, 2012 9:26 am
Posts: 2
Thanks for the explanation, but how can I solve my 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.