GORM, Dynamic Finders, and Lists

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GORM, Dynamic Finders, and Lists

CJ Fleck
It is an odd hour, so maybe I just need sleep, but I'm having a
problem setting up a query.  For setup, I have two domain classes...

class A {
    static hasMany = [bs:B]
}

class B {
    int foo
}

I'm trying to write a query that will tell me if a particular instance
of B exists in multiple instances of A's bs list.  That is, given B
bInstance1, give me all the instances of A for which bInstance is a
part of.

aInstance1.bs = [bInstance1, bInstance2]
aInstance2.bs = [bInstance1]
aInstance1.bs = [bInstance2]

With the above objects, I want a query that returns aInstance1 and
aInstance2.  I want to just write a straight sql query to do this for
me since that seems very easy (especially at this hour), but I figure
there is likely a better way and I should probably learn it.

Any advice?

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: GORM, Dynamic Finders, and Lists

elvanor
Look into criterias. I am sure you can achieve what you want with a criteria

On Sat, Oct 30, 2010 at 12:37 PM, CJ Fleck <[hidden email]> wrote:
It is an odd hour, so maybe I just need sleep, but I'm having a
problem setting up a query.  For setup, I have two domain classes...

class A {
   static hasMany = [bs:B]
}

class B {
   int foo
}

I'm trying to write a query that will tell me if a particular instance
of B exists in multiple instances of A's bs list.  That is, given B
bInstance1, give me all the instances of A for which bInstance is a
part of.

aInstance1.bs = [bInstance1, bInstance2]
aInstance2.bs = [bInstance1]
aInstance1.bs = [bInstance2]

With the above objects, I want a query that returns aInstance1 and
aInstance2.  I want to just write a straight sql query to do this for
me since that seems very easy (especially at this hour), but I figure
there is likely a better way and I should probably learn it.

Any advice?

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email