Grails

ability to obtain the id of related objects without loading the entire object

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.0.2
  • Component/s: None
  • Labels:
    None

Description

Person hasMany Things
Thing belongsTo Person

You should be able to access the id of the Person a Thing belongs to without having to load the entire Person object since it exists in the Things database record

possible syntax

myThing.personId
myThing.properties['personId'[

My only concern is creating a syntax that works when the Thing belongsTo two different Person objects.

Activity

Hide
Wang Qi added a comment -

I suggest the best syntax should be normal property access, such as thing2.person.id. Hibernate already do that for proxy association.

please check http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-fetching-proxies

in section 19.1

"Proxy fetching - a single-valued association is fetched when a method other than the identifier getter is invoked upon the associated object."

an interesting thing is when i access thing2.person.class. GORM also load the person record from database.

WangQi

Show
Wang Qi added a comment - I suggest the best syntax should be normal property access, such as thing2.person.id. Hibernate already do that for proxy association. please check http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-fetching-proxies in section 19.1 "Proxy fetching - a single-valued association is fetched when a method other than the identifier getter is invoked upon the associated object." an interesting thing is when i access thing2.person.class. GORM also load the person record from database. WangQi
Hide
Graeme Rocher added a comment -

this was fixed in 1.0.2

Show
Graeme Rocher added a comment - this was fixed in 1.0.2

People

Vote (3)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: