Java Mailing List Archive

http://www.junlu.com/

Home » user.castor »

[castor-user] how to loop object result set and update while
checking against earlier updated object

olmec

2012-12-19

Replies: Find Java Web Hosting

Author LoginPost Reply

Ok, so what I am trying to do is loop through all objects in a query result
and update each one at a time while checking a particular property value is
unique. If it is not unique then I will make it unique.

Hope this makes sense. Here is the code I have so far:

while ( results.hasMore() ){
  product = (model.objects.Product)results.next();
                   
  if(product.getUrl() == null) {
    product.setUrl(product.getCaption());
  }
       
  if(UrlInUse(product.getUrl()) {
    product.setUrl(product.getUrl() + product.getProductId());
  }
}

UrlInUse function does a query to check if any product already uses the
given url. This works and is used in other parts of the application. I
assume the problem is to do with begin and commit....

Any help much appreciated.
--
Sent from the Castor - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


©2008 junlu.com - Jax Systems, LLC, U.S.A.