|
Hi, I'm using a service that internally uses the Hibernate Criteria Builder
to construct complex criterias based on params parsing. Can I somehow print out the DSL (or whatever it is called) that has been constructed? Ie, I am trying to print out, as a string, this part... criteriaClosure = {...which is subsequently sent to the Criteria Builder./Claes |
|
On Fri, Feb 11, 2011 at 8:50 AM, Claes Svensson <[hidden email]> wrote:
> Hi, I'm using a service that internally uses the Hibernate Criteria Builder > to construct complex criterias based on params parsing. Can I somehow > print out the DSL (or whatever it is called) that has been constructed? > > Ie, I am trying to print out, as a string, this part... > > criteriaClosure = { > projections { > groupProperty("branch") > } > like("holderFirstName", "Fred%") > and { > between("balance", 500, 1000) > eq("branch", "London") > } > maxResults(10) > order("holderLastName", "desc") > } > > ...which is subsequently sent to the Criteria Builder. > > /Claes > I think the answer to your questions is that there isn't really a simple way to do that. However, I am curious to know why you want to do that. It may be that there is a better way to accomplish your goal. jb -- Jeff Brown SpringSource http://www.springsource.com/ Autism Strikes 1 in 166 Find The Cause ~ Find The Cure http://www.autismspeaks.org/ --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
No worries, if it's hard to do then I don't need it. It would only be a lazy approach for
me to find out the constructed Hibernate Criteria, there shouldn't be much trouble finding this out from the code itself. Thanks for your answer, Claes > Date: Fri, 11 Feb 2011 09:12:18 -0600 > From: [hidden email] > To: [hidden email] > Subject: Re: [grails-user] Printing the DSL for the Hibernate Criteria Builder? > > On Fri, Feb 11, 2011 at 8:50 AM, Claes Svensson <[hidden email]> wrote: > > Hi, I'm using a service that internally uses the Hibernate Criteria Builder > > to construct complex criterias based on params parsing. Can I somehow > > print out the DSL (or whatever it is called) that has been constructed? > > > > Ie, I am trying to print out, as a string, this part... > > > > criteriaClosure = { > > projections { > > groupProperty("branch") > > } > > like("holderFirstName", "Fred%") > > and { > > between("balance", 500, 1000) > > eq("branch", "London") > > } > > maxResults(10) > > order("holderLastName", "desc") > > } > > > > ...which is subsequently sent to the Criteria Builder. > > > > /Claes > > > > I think the answer to your questions is that there isn't really a > simple way to do that. However, I am curious to know why you want to > do that. It may be that there is a better way to accomplish your > goal. > > > > jb > -- > Jeff Brown > SpringSource > http://www.springsource.com/ > > Autism Strikes 1 in 166 > Find The Cause ~ Find The Cure > http://www.autismspeaks.org/ > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > |
|
I know this isn't printing out the closure code, but in case you didn't know ...
you can have hibernate log the resulting SQL in couple of different ways in dataSource set logSql = true to get formatted statements without values or in the log4j config set trace 'org.hibernate.SQL', 'org.hibernate.type' to get unformatted statements, but with values I find this most helpful when trying to sort out what's happening with some criteria of mine. |
| Powered by Nabble | Edit this page |
