|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
CreateCriteria on more than one tableHi ,
I have a hibernate createCriteria as follows: Criteria criteria = getSession().createCriteria(OfferCredit.class); criteria.createCriteria("offer").add( Restrictions.eq("status", LeverageUtils.ACTIVE_STATUS)).add( Restrictions.ge("expirationDate", new Date())); criteria.createCriteria("user").add(Restrictions.eq("userId", userId)); criteria.add(Restrictions.eq("status", LeverageUtils.ACTIVE_STATUS)); criteria.addOrder(Order.asc("creationDate")); list = criteria.list(); where OfferCredit, Offer and User are tables. I want the OfferCredit if the offer in Offer table is active and the user in User table is active.(OfferCredit table has offer and user but has no reference if they are active.So i need to check with offer and user table) My OfferCredit.groovy has User and Offer Please help me with creating criteria(in grails) same as above. |
|
|
Re: CreateCriteria on more than one tableIt would be something like this:
def criteria = OfferCredit.createCriteria { offer { eq('status', LeverageUtils.ACTIVE_STATUS) ge('expirationDate',new Date()) } user { eq('userId', userId) } eq(''status', LeverageUtils.ACTIVE_STATUS) order('creationDate', 'asc') } criteria.list() See http://grails.org/doc/1.0.x/guide/5.%20Object%20Relational%20Mapping%20(GORM).html#5.4.2%20Criteria for more details On May 7, 2008, at 1:38 AM, Jayanthisri wrote: > > Hi , > > I have a hibernate createCriteria as follows: > > Criteria criteria = getSession().createCriteria(OfferCredit.class); > criteria.createCriteria("offer").add( > Restrictions.eq("status", LeverageUtils.ACTIVE_STATUS)).add( > Restrictions.ge("expirationDate", new Date())); > criteria.createCriteria("user").add(Restrictions.eq("userId", > userId)); > criteria.add(Restrictions.eq("status", > LeverageUtils.ACTIVE_STATUS)); > criteria.addOrder(Order.asc("creationDate")); > list = criteria.list(); > > > where OfferCredit, Offer and User are tables. I want the > OfferCredit if > the offer in Offer table is active and the user in User table is > active.(OfferCredit table has offer and user but has no reference if > they > are active.So i need to check with offer and user table) > > My OfferCredit.groovy has User and Offer > > Please help me with creating criteria(in grails) same as above. > > > -- > View this message in context: http://www.nabble.com/CreateCriteria-on-more-than-one-table-tp17098332p17098332.html > Sent from the grails - dev mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: CreateCriteria on more than one tableThanks !
|
| Free Forum Powered by Nabble | Forum Help |