Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

[neo4j] lazy loading associations not possible? #34

Closed
mcphilip opened this issue Mar 22, 2012 · 2 comments
Closed

[neo4j] lazy loading associations not possible? #34

mcphilip opened this issue Mar 22, 2012 · 2 comments
Labels

Comments

@mcphilip
Copy link

Consider the following simple neo4j mapped domain classes:

class Organization {
String name

static hasMany = [people: Person]

static mapWith = "neo4j"

static mapping = {
    people(lazy: true)
}

}

class Person {
String firstName
String lastName

static mapWith = "neo4j"

static constraints = {
        firstName(nullable: false, blank: false, maxSize: 500)
        lastName(nullable: false, blank: false, maxSize:  500)
}

static belongsTo = [organization: Organization]

}

My testing so far seems to indicate that the lazy: true mapping in the Organization domain class is not respected since the time it take to load an organization record greatly slows own as the number of people associated with is increased.

Is the lazy collection loading in neo4j gorm intended to be supported? I apologize if I missed something in the existing documentation already explaining this.

Thanks,
Phil

@sarmbruster
Copy link
Contributor

The plugin uses a optimization when detecting dirty objects upon session flushing if the domain classes if the domain class is annotated with:

 @groovy.beans.Bindable
 class Organization { ... }

Could you please check and see, if the "load organization" performs better with that in place? Add @Bindale to all domain classes.

@amadfida
Copy link

This seems to be broken in latest SNAPSHOT version, as adding @bindable has not effect due to the following code,

static memoizePropertyChangeListener = Collections.synchronizedMap([:].withDefault() { false }) .... if (memoizePropertyChangeListener[object.class] == true)

this always returns false.

I think of the commentted code is uncommented , it should work fine.

def instanceSupportsPropertyChangeListener = { Class clazz -> clazz.respondsTo("addPropertyChangeListener")}.memoize()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

4 participants