Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-22-2019 01:14 PM
Weird question, but I can't find any related docs. In most cases, whenever I'm mapping through @Relationship entities, the source
and target
nodes have differing labels / model classes. Now I have a case where I need to map sources and targets of the same label / model class. This appears to trip up the OGM, and it doesn't know which of the returned nodes should be the source and which the target, even though the relationship is clearly indicated (and returned by the query).
Does this sound like an unsupported mapping, or more like I'm doing it wrong? Code example:
@NodeEntity
data class Thing(@Id @GeneratedValue(strategy = UuidStrategy::class) var uuid: String? = null,
@Relationship(type = "AUGMENTS", direction = Relationship.OUTGOING
var augments: List<ThingAugments>? = null) { ... }
@RelationshipEntity(type = "AUGMENTS")
data class ThingAugments(@Id @GeneratedValue var id: Long? = null,
@Property(name = "order") var order: Long? = null,
@StartNode var source: Thing? = null,
@EndNode var target: Thing? = null)
02-22-2019 05:49 PM
Nevermind – this was an issue with my (overly complicated) cypher query.
02-22-2019 08:01 PM
Oops. Fixing the cypher corrected the mapping problem. And while it now maps the (t1:Thing)-[:AUGMENTS]->(t2:Thing)
properly, it also spills all the t2
's to the top level, returning an array of Things. This will break e.g. calls that return a single object versus a list, and generally adds noise.
But it makes sense – I guess OGM must return all objects matching return type. I have no idea how to address this one, though. And sorry – this is specifically via SDN, using custom @Query
on Repository calls.
02-24-2019 11:38 PM
I assume that it is related to this GitHub issue https://github.com/neo4j/neo4j-ogm/issues/496 that was solved with this commit: https://github.com/neo4j/neo4j-ogm/commit/3532cc0f02b5e768dee15720b2e858991fc9124a
You may test it by using the latest Spring Data Neo4j Moore Milestone (M1) and set the Neo4j-OGM version to 3.2.0-alpha04.
02-25-2019 02:55 PM
Perhaps, but for me it happens whether or not I'm using a pattern comprehension. But, if I do send the same @Query
as would have been sent (or at least, logged) from e.g. FindBy*
(which uses comprehensions), it exhibits the issue. Yet works for FindBy* – (?)
03-04-2019 08:11 AM
@gerrit.meier Thank you for the advice. Unfortunately, I am unable to get this combination of releases working in my project:
Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NoSuchMethodError: org.neo4j.ogm.config.Configuration.mergeBasePackagesWith([Ljava/lang/String;)[Ljava/lang/String;
05-24-2019 07:32 PM
Sorry to raise the dead here, but I find I still have strange mapping reports, all the while mapping is working perfectly. I get a lot of this, is it normal?
ERROR 3537 --- [ctor-http-nio-4] org.neo4j.ogm.context.GraphEntityMapper : Found more than one matching @RelationshipEntity for (9596)-[PRESENTS]->(9610) but cannot tell which one to use
This relates to my original post because it has to do with the same root issue: either I fundamentally misunderstand how the mapper works, or the mapper has a fundamental weakness in regards to directionality.
All the sessions of the conference are now available online