Grails ORM Join

18 views
Skip to first unread message

Sudhakar Vaddi

unread,
Jun 18, 2010, 3:44:32 AM6/18/10
to ig...@googlegroups.com
Hi,

I have two domain objects Person and Address.
Person hasmany addresses.

I need join these two using Criteria Builder. Below is the SQL :

select * from Person p, Address a where p.address_id = a.id and p.id=?

How to convert this into Criteria in Grails?

Appreciate your help.

Thanks
Sudhakar

uday

unread,
Jun 18, 2010, 5:14:28 AM6/18/10
to Indian Groovy & Grails User Group

karthi

unread,
Jun 21, 2010, 10:40:44 AM6/21/10
to ig...@googlegroups.com
If you want to query person for given address.id, the following is the code

Person.createCriteria().list{
       address{
              eq("id",some_address_id)
        }
}

else if you want all person with corresponding addresss

Person.list()

the above should suffice, its object orientation.


On Fri, Jun 18, 2010 at 2:44 PM, uday <meuday...@gmail.com> wrote:
On Jun 18, 12:44 pm, Sudhakar Vaddi <vaddi.sudha...@googl{email.com>
Reply all
Reply to author
Forward
0 new messages