tags:

views:

17

answers:

1

i use webflow in a my grails application, i have 2 tables with relation ManyToMany in hibernate mode. this relation as u know, creates a table with 2 primary keys of the original tables, both be the primary key of the third table.

my tables are destination and destinationGroup.

i write a select statement with dynamic finders to have a list of destnation group that has specific destination. i try these ways and no effect for any one: 1-

def DestinationInstance = Destination.get(params.destination)
   flow.DestinationGroupList  = DestinationGroup.executeQuery("select distinct d.name,d.description from DestinationGroup d where d.destinations = :p",[p:DestinationInstance])

2-

def DestinationInstance = Destination.get(params.destination)
flow.destinationGroupList = DestinationGroup.findAllWhere(Destinations:destinationInstance)

3-

def DestinationInstance = Destination.get(params.destination)
   flow.destinationGroupList = DestinationGroup.findAll("from DestinationGroup as d where  d.destinations =:p", [p:destinationInstance]

)

these 3 statement has no effect, if there is any why for solving this problem please till me about it. thanks

+1  A: 

Have you tried a Criteria query?

def c = DestinationGroup.createCriteria()
flow.destinationGroupList = c.list{
         destinations{
             idEq(destinationInstance.id)
         }
    }

cheers

Lee

leebutts
thanks it works fine
mbayloon