Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-28-2018 07:29 AM
This is going to sound like a bit daft, but is there any way to do custom mapping in a Neo4jRepository after the OGM finishes its work? What I'm trying to achieve is to include a nodes "parent" uuid
in a tree-like graph, but not actually include that parent in the mapped results. (A new requirement I hadn't anticipated, and a lot of repositories to affect.)
For instance, if I have (book)-[on]->(shelf), and someone requests the book, I want to return the book but also inject the shelf's uuid
as a property on the returned book.
I came across some esoteric references to Neo4jTemplate
, but couldn't find much even about that. I am just hoping to avoid rebuilding everything just to achieve this seemingly minor change. I hold little hope, but any hints are appreciated.
I guess another approach would be to build an extension function to decorate a given node before it gets back to the OGM.
11-28-2018 11:05 AM
I went with the latter approach, which works, except: is there any way to make the injected property transient in the returned node? When I set the property, the default transaction goes ahead and persists the change, which is not so desirable.
I don't think I can use projection or a virtual node, as the source node is deeply connected, and those connections need to be reflected so the OGM can map them. I suppose I could generate a virtual copy of the entire subgraph, but that seems like overkill simply to inject one property.
Any other way to achieve this?
12-03-2018 11:43 AM
You could also create a field in the Book
class and add the @Transient
annotation.
Do I understand this correct? You are adding the shelf id with your change and there was no reference before(?)
All the sessions of the conference are now available online