Difference between eq and == in Grails withCriteria query -


i want fetch db requirements related given project(in case currentproject) i've used 2 ways this

first 1 :

requirement.withcriteria {....     eq("project", currentproject)     ... } 

i note query doesn't use equals method of project class, query returns me want.

second

requirement.withcriteria {     ....             currentproject == property('project')     ... } 

this query use equals method compare 2 projects, not overwrite equals method exception has been thrown saying "grails can't cast hibernatebuild domain"

so, wonder know difference between 2 queries ?

thanks all!

withcriteria method goes database fetch entities.

on database level there no concept of equals (db not know java). first query gives right results because compares db mapping (primary / foreign keys).

as second query - not advice use it. if uses equals, when fetches projects db memory. , bad idea.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -