Closed spring-projects-issues closed 7 years ago
chris commented
Might be related to DATAGRAPH-145 ?
Michael Hunger commented
How exactly did you use GraphRepository? Please share that code too and the repo declaration
chris commented
Only extended the GraphRepository;
So without the @Typealias
in the entities, it is able to return a Set of Concrete Pet Class
public interface PetRepository extends GraphRepository<Pet> {
}
@Configuration
@EnableNeo4jRepositories(basePackages = "com.test.maincore.repository")
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
public class Neo4JConfig extends Neo4jConfiguration {
@Bean
public TypeRepresentationStrategyFactory typeRepresentationStrategyFactory() throws Exception {
return new TypeRepresentationStrategyFactory(graphDatabase(), getStrategy(), indexProvider());
}
protected Strategy getStrategy() {
return Strategy.Labeled;
}
}
Paulo Sérgio Medeiros dos Santos commented
Very same problem here, but with version 2.3.5: removing typealias from the inheritance classes and SDN works correctly.
Seems like an old problem (DATAGRAPH-145?), very difficult to trace though. Also, notice that in the case of using typealias, when I do a save before the first find, then SDN works correctly too. See the last comment on: http://forum.spring.io/forum/spring-projects/data/nosql/118586-inheritance-question-for-spring-data-neo4j => " I am using TypeAlias as well, and things do not appear to work correctly until I do a first save".
One difference from the scenario described above and my case is that the "inheritance problem" appears indirectly via entities relations. Here is the description (extending the Pet example described above).
@NodeEntity
public class Person {
@RelatedTo(type="PETS", direction = Direction.OUTGOING)
private Set<Pet> pets;
}
In this case, when I call personRepository.findAll(), then the exception is thrown: org.springframework.data.neo4j.mapping.InvalidEntityTypeException: Unable to legally create entity : class com.test.maincore.domain.Pet
Nicki Watt commented
I have tried to replicate this issue using the latest stable SDN (3.0.2.RELEASE) and Neo4j (2.0.1) releases, however have not been able to. The issue was raised with an older milestone version of SDN. I have attached a zip file which contains a test replicating what I understand to be your issue. Could you please confirm if your issue still exists with 3.0.2.RELEASE, and whether the supplied zip file containing the test cases is indeed an accurate reflection of your problem. Thanks Nicki
Nicolas Mervaillie commented
In order to give users a better vision of what’s happening on SDN, we are bulk closing several issues because they are no more relevant, or related to old and un-maintained SDN versions. We tried to keep the issues that are still relevant, like feature requests that are still absent from SDN. However, some may have been closed by error. If so, please feel free to reopen.
chris opened DATAGRAPH-426 and commented
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)
Affects: 3.0 M1 (Codd)
Attachments:
1 votes, 5 watchers