You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2009/11/13 01:04:45 UTC
svn commit: r835650 -
/ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy
Author: doogie
Date: Fri Nov 13 00:04:44 2009
New Revision: 835650
URL: http://svn.apache.org/viewvc?rev=835650&view=rev
Log:
Example showing how the sql parser works.
Added:
ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy
Added: ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy?rev=835650&view=auto
==============================================================================
--- ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy (added)
+++ ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy Fri Nov 13 00:04:44 2009
@@ -0,0 +1,33 @@
+import java.util.concurrent.Callable
+import org.ofbiz.entity.sql.Parser
+import org.ofbiz.entity.transaction.TransactionUtil
+response.contentType = 'text/html'
+def delegator = request.delegator
+def sql = """
+select
+ a.*,
+ b.firstName,
+ b.lastName
+FROM
+ Party a JOIN Person b ON a.partyId = b.partyId
+WHERE
+ a.partyId='admin'
+OFFSET 5
+LIMIT 10
+;
+"""
+def parser = new Parser(new ByteArrayInputStream(sql.bytes))
+def sqlSelect = parser.Select()
+
+TransactionUtil.doNewTransaction("Test", [call: {
+ def eli
+ try {
+ eli = sqlSelect.getEntityListIterator(delegator)
+ def gv;
+ while ((gv = eli.next()) != null) {
+ println("gv=$gv")
+ }
+ } finally {
+ if (eli != null) eli.close()
+ }
+}] as Callable)
Re: svn commit: r835650 - /ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy
Posted by Adam Heath <do...@brainfood.com>.
doogie@apache.org wrote:
> Author: doogie
> Date: Fri Nov 13 00:04:44 2009
> New Revision: 835650
>
> URL: http://svn.apache.org/viewvc?rev=835650&view=rev
> Log:
> Example showing how the sql parser works.
http://localhost:8080/webslinger/TestSQL
Then look at the output in your console. You'll see one println,
gv="something"