Re: MappedSelect/SQLTemplate #chain and #chunk directives

"Jurgen Doll" <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <0281151A4F274EA6ACD194FAC109B6C0@IV5>
Hi John

Just add the parameters like you normally would when using #bind on its own, 
like so:

queryParameters.put( "thing1", new Integer(9) );
queryParameters.put( "thing2", new Timestamp( ... ) );

Jurgen


-----Original Message----- 
From: John Huss
Sent: Thursday, October 3, 2019 12:12 AM
To: [email protected]
Subject: MappedSelect/SQLTemplate #chain and #chunk directives

Looking at the docs
<https://cayenne.apache.org/docs/4.0/cayenne-guide/#queries> for
MappedSelect/SQLTemplate I'm not clear on how to supply the parameters for
the #chain and #chunk directives from the java side. How should I structure
this data and pass it to the SQLTemplate query?

SQL:
#chain('OR' 'AND')
    #chunk($thing1) thing1  = #bind($thing1, 'INTEGER') #end
    #chunk($thing2) thing2 >= #bind($thing2, 'TIMESTAMP') #end
#end"

Java:

Map<String, Object> queryParameters = *new* HashMap<>(2);

queryParameters.put(*?*);


MappedSelect<MyEntity> query = MappedSelect.*query*(MyDataMap.
*MYQUERY_QUERYNAME*, MyEntity.*class*).params(queryParameters);



Thanks.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.