(Quick Reference)

createInstanceForNode

Purpose

Retrieve a domain class instance associated with the given node.

Example

Assume some domain class:

class Person {
    String name
}

def person = new Person(name:'Joe')
person.save(flush:true)

// somewhere later

Node node = .... // some code returning a Neo4j node def samePerson = Person.createInstanceForNode(node)

// works also with nodeId samePerson = Person.createInstanceForNode(person.id)

Description

def createInstanceForNode(nodeOrId)

createInstanceForNode may by invoke statically on each domain class and returns a domain class instance that is represented by that node.

Arguments

nodeOrId: a Neo4j node or the node's id

Return value

A domain class instance or null if the node does not represent an entity.