• Add a Comment
  • Edit
  • More Actions v
  • Quarantine this Entry

Comments (2)

1 localhost commented Trackback

Thats a good informative article.

 
- Varun Mandadi

2 localhost commented Trackback

Project Zero's "Zero Resource Model" offers the functionality of URI to SQL for partial lists as you have described. If "prodcut" is set up as a model, the following URI does this:

 
http://host/resource/product?id__in=23,24,44,33
 
And this will generate and execute the following SQL as a PreparedStatement and bind the parameters:
 
SELECT * FROM product WHERE id IN (?,?,?,?)
 
Further, if you are using Zero's SQL support from Groovy, you can do the following "list expansion":
 
def list = [23,24,44,33]def results = queryList("SELECT * FROM product WHERE id IN $list")
 
This will expand the list to "(?,?,?,?)", prepare the SQL statement, bind the parameters, and execute.

Add a Comment Add a Comment