|
Hi all,
Just a small question: I'm trying to retreive some entities from my databases (Recipes in this case), and I'm using this query for that (simplified version): def recipes = Recipe.findAll("from net.javaisp.cookbook.Recipe as r inner join r.ingredients as i ") However, this doesn't return Recipe objects, but Object arrays of length 2, with Recipe and Ingredient classes. How can I prevent this from happening and only return Recipes? I tried this: def recipes = Recipe.findAll("select r from net.javaisp.cookbook.Recipe as r inner join r.ingredients as i"); But this is an incorrect query: "errors.GrailsExceptionResolver org.codehaus.groovy.grails.orm.hibernate.exceptions.GrailsQueryException: Invalid query [select r from net.javaisp.cookbook.Recipe as r inner join r.ingredients as i] for domain class ......" Suggestions?? |
|
I'm not used to HQL, but I guess that the inner join forces the retrieval of both entities.
I would do something like "from A where A.b is not null" hTh,
Miguel Ping
On Mon, Jan 12, 2009 at 8:22 AM, Erik Pragt <[hidden email]> wrote:
|
|
In reply to this post by Erik Pragt-2
Hi, I have the same problem, I would like to use the select closure like hibernate allows in HQL ( see examples in : ) http://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/queryhql.html#queryhql-aggregation This HQL sentence is not possible currently in GORM, it would be very nice to have it :) I am using grails 1.3.7 def theResult = Foo.findAll("select foo from Foo foo, SubFoo subfoo where foo.subfooProperty= subfoo") Best Regards |
| Powered by Nabble | Edit this page |
