Generic and Abstract Relationship Entity
See original GitHub issueWe have the following scenario: 2 NodeEntity
class (A and B) linked by a RelationshipEntity
(L) which is abstract and parametrized.
Here a simple stub of our classes:
@RelationshipEntity
public abstract class L<T> {
private T property;
@StartNode
private A a;
@EndNode
private B b;
}
@NodeEntity
public final class A <T> {
@Relationship
private List<L<T>> listOfLs;
}
@NodeEntity
public final class B {
//some stuff here
}
We have two kind of problems concerning listOfLs relationship:
- the first is related to the closed bug (https://github.com/neo4j/neo4j-ogm/issues/45) and involves the dynamic binding of classes extending the (abstract) L class. For example, if CL1 and CL2 extend L, the OGM does not seem to correctly save the objects with the right subtype (CL1 or CL2) without specify the relathionship type (for our use cases is impossible to define it at compile time).
- the second issue is related to type parameter in generic class handling. The use of generic type in the element of the listOfLs throws the exception below:
Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: it.cnr.ilc.lc.omega.entity.L<TT
at org.neo4j.ogm.metadata.ClassUtils.getType(ClassUtils.java:94)
at org.neo4j.ogm.mapper.EntityGraphMapper.mapEntityReferences(EntityGraphMapper.java:237)
at org.neo4j.ogm.mapper.EntityGraphMapper.mapEntity(EntityGraphMapper.java:158)
at org.neo4j.ogm.mapper.EntityGraphMapper.map(EntityGraphMapper.java:91)
at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:67)
at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:43)
at org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:386)
at it.cnr.ilc.lc.omega.test.Tester.test6(Tester.java:247)
at it.cnr.ilc.lc.omega.test.Tester.main(Tester.java:43)
Caused by: java.lang.ClassNotFoundException: it.cnr.ilc.lc.omega.entity.L<TT
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.neo4j.ogm.metadata.classloader.MetaDataClassLoader.loadClass(MetaDataClassLoader.java:34)
at org.neo4j.ogm.metadata.ClassUtils.getType(ClassUtils.java:92)
... 8 more
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Generic Relationships in Information Modeling | SpringerLink
Generic relationships are abstraction patterns used for structuring information across application domains. They play a central role in information modeling.
Read more >Generic Relationships in Information Modeling 1 Introduction
Generic relationships are powerful abstraction mechanisms that help in better organizing infor- mation during the analysis phase of problem resolution. Recent ...
Read more >Add a relationship entity in generic/abstract way - Stack Overflow
I'm trying to write a WCF method that will receive a detached EntityObject from the client and will be able to tell which...
Read more >Representation of Generic Relationship Types in Conceptual ...
Abstract and Figures. A generic relationship type is a relationship type that may have several realizations in a domain.
Read more >[PDF] Generic Relationships in Information Modeling
A list of dimensions to characterize the semantics of generic relationships in a clear and systematic way is defined, drawn from a careful...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any solution for this?
I think the user is trying to link A and B type nodes with relationships that have properties of a certain type. This would be useful for querying the graph by relationship property type. This is a more suitable use case for Cypher.