org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Type class java.lang.String is neither a @NodeEntity nor a @RelationshipEntity

Spring JIRA | Victor Cvetanov | 4 years ago
  1. 0

    When attempting .equals() on instance of @NodeEntity annotated class against instance of some non-@NodeEntity annotated class an exception is thrown. In my opinion it should just return false with no exceptions. @NodeEntity public class Person { ... } Person person = ....;// some loading from the Graph database person.equals("some string here"); //throws the exception Exception in thread "main" org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Type class java.lang.String is neither a @NodeEntity nor a @RelationshipEntity at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.createPersistentEntity(Neo4jMappingContext.java:56) at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.createPersistentEntity(Neo4jMappingContext.java:46) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:271) at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.addPersistentEntity(Neo4jMappingContext.java:61) at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.addPersistentEntity(Neo4jMappingContext.java:46) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:183) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:158) at org.springframework.data.neo4j.support.mapping.EntityStateHandler.getId(EntityStateHandler.java:82) at org.springframework.data.neo4j.support.mapping.EntityStateHandler.getPersistentState(EntityStateHandler.java:99) at org.springframework.data.neo4j.support.mapping.EntityStateHandler.equals(EntityStateHandler.java:260) at org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$equals(Neo4jNodeBacking.aj:235) ....

    Spring JIRA | 4 years ago | Victor Cvetanov
    org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Type class java.lang.String is neither a @NodeEntity nor a @RelationshipEntity
  2. 0

    When attempting .equals() on instance of @NodeEntity annotated class against instance of some non-@NodeEntity annotated class an exception is thrown. In my opinion it should just return false with no exceptions. @NodeEntity public class Person { ... } Person person = ....;// some loading from the Graph database person.equals("some string here"); //throws the exception Exception in thread "main" org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Type class java.lang.String is neither a @NodeEntity nor a @RelationshipEntity at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.createPersistentEntity(Neo4jMappingContext.java:56) at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.createPersistentEntity(Neo4jMappingContext.java:46) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:271) at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.addPersistentEntity(Neo4jMappingContext.java:61) at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.addPersistentEntity(Neo4jMappingContext.java:46) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:183) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:158) at org.springframework.data.neo4j.support.mapping.EntityStateHandler.getId(EntityStateHandler.java:82) at org.springframework.data.neo4j.support.mapping.EntityStateHandler.getPersistentState(EntityStateHandler.java:99) at org.springframework.data.neo4j.support.mapping.EntityStateHandler.equals(EntityStateHandler.java:260) at org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$equals(Neo4jNodeBacking.aj:235) ....

    Spring JIRA | 4 years ago | Victor Cvetanov
    org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Type class java.lang.String is neither a @NodeEntity nor a @RelationshipEntity
  3. 0

    Type class java.lang.RuntimeException is neither a @NodeEntity nor a @RelationshipEntity

    Stack Overflow | 4 years ago | user1971430
    org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Type class java.lang.RuntimeException is neither a @NodeEntity nor a @RelationshipEntity
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    SpringData/Neo4j: cannot persist relationship

    Stack Overflow | 5 years ago | Rolf
    org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Type class org.springframework.data.neo4j.fieldaccess.GraphBackedEntityIterableWrapper is neither a @NodeEntity nor a @RelationshipEntity
  6. 0

    With the following node entities and using GraphRepository I can write to the db, but cannot read back out. If I remove the TypeAlias, it works however you have to use the long name of the Entity so in the cypher you cannot use n:Pet but n:`com.test.entity.Pet` Example: @NodeEntity @TypeAlias("Pet") public abstract class Pet { } @NodeEntity @TypeAlias("Dog") public class Dog extends Pet { } @NodeEntity @TypeAlias("Cat") public class Cat extends Pet { } Stack Trace: org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Unable to legally create entity : abstract/interface class specified : class com.test.maincore.domain.Pet at org.springframework.data.neo4j.support.mapping.AbstractConstructorEntityInstantiator.createEntityFromState(AbstractConstructorEntityInstantiator.java:68) at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister$CachedInstantiator.createEntityFromState(Neo4jEntityPersister.java:135) at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister$CachedInstantiator.createEntityFromState(Neo4jEntityPersister.java:122) at org.springframework.data.neo4j.support.mapping.Neo4jEntityConverterImpl.read(Neo4jEntityConverterImpl.java:98) at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister$CachedConverter.read(Neo4jEntityPersister.java:170) at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.createEntityFromState(Neo4jEntityPersister.java:189) at org.springframework.data.neo4j.support.Neo4jTemplate.createEntityFromState(Neo4jTemplate.java:195) at org.springframework.data.neo4j.repository.AbstractGraphRepository.createEntity(AbstractGraphRepository.java:209) at org.springframework.data.neo4j.repository.AbstractGraphRepository.findOne(AbstractGraphRepository.java:151) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:344) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:329) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy41.findOne(Unknown Source) at com.test.TestingRead.testname(TestingRead.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

    Spring JIRA | 3 years ago | chris
    org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Unable to legally create entity : abstract/interface class specified : class com.test.maincore.domain.Pet

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.data.neo4j.mapping.InvalidEntityTypeException

      Type class java.lang.String is neither a @NodeEntity nor a @RelationshipEntity

      at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.createPersistentEntity()
    2. Spring Data Neo4j
      Neo4jMappingContext.createPersistentEntity
      1. org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.createPersistentEntity(Neo4jMappingContext.java:56)
      2. org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.createPersistentEntity(Neo4jMappingContext.java:46)
      2 frames
    3. Spring Data Core
      AbstractMappingContext.addPersistentEntity
      1. org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:271)
      1 frame
    4. Spring Data Neo4j
      Neo4jMappingContext.addPersistentEntity
      1. org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.addPersistentEntity(Neo4jMappingContext.java:61)
      2. org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.addPersistentEntity(Neo4jMappingContext.java:46)
      2 frames
    5. Spring Data Core
      AbstractMappingContext.getPersistentEntity
      1. org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:183)
      2. org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:158)
      2 frames
    6. Spring Data Neo4j
      EntityStateHandler.equals
      1. org.springframework.data.neo4j.support.mapping.EntityStateHandler.getId(EntityStateHandler.java:82)
      2. org.springframework.data.neo4j.support.mapping.EntityStateHandler.getPersistentState(EntityStateHandler.java:99)
      3. org.springframework.data.neo4j.support.mapping.EntityStateHandler.equals(EntityStateHandler.java:260)
      3 frames
    7. Spring Data Neo4j - AspectJ Advanced Mapping
      Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$equals
      1. org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$equals(Neo4jNodeBacking.aj:235)
      1 frame