question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generic and Abstract Relationship Entity

See original GitHub issue

We 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:

  1. 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).
  2. 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:closed
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ArashJalaliancommented, May 21, 2018

Any solution for this?

0reactions
mihairauleacommented, Apr 13, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found