I just find what I consider a bug on the Cross store support of spring-data-neo4j.
I've noticed different behaviors on class org.springframework.data.neo4j.cross_store.support .node.CrossStoreNodeEntityInstantiator regarding the state synchronization between the graph and the relational database.
When n is an instance of RestNode (that means your're using a remote REST Neo4j server) the n.getProperty(CrossStoreNodeEntityState.FOREIGN_ID ) returns a java.lang.Integer. When using a local database, it returns java.lang.Long. Since my id is a Long (and the spring-data-neo4j docs tells that it should be Long indeed), Hibernate (my JPA provider) throws an exception on find telling me that an id of the wrong type was provided:Code:public <T> T createEntityFromState(Node n, Class<T> entityClass, final MappingPolicy mappingPolicy) { if (n.hasProperty(CrossStoreNodeEntityState.FOREIGN_ID)) { final Object foreignId = n.getProperty(CrossStoreNodeEntityState.FOREIGN_ID); final T result = entityManager().find(entityClass, foreignId); ((NodeBacked)result).setPersistentState(n); return result; } return delegate.createEntityFromState(n, entityClass, mappingPolicy); }
I'm not sure if RestNode should return an Integer, but even if it should, spring-data-neo4j should convert it since it tells you to use Long ids.Code:org.springframework.dao.InvalidDataAccessApiUsageException: Provided id of the wrong type for class [MY_CLASS]. Expected: class java.lang.Long, got class java.lang.Integer; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class [MY_CLASS]. Expected: class java.lang.Long, got class java.lang.Integer at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:296) at org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect.ajc$afterThrowing$org_springframework_orm_jpa_aspectj_JpaExceptionTranslatorAspect$1$18a1ac9(JpaExceptionTranslatorAspect.aj:15) at org.springframework.data.neo4j.cross_store.support.node.CrossStoreNodeEntityInstantiator.createEntityFromState(CrossStoreNodeEntityInstantiator.java:59) at org.springframework.data.neo4j.cross_store.support.node.CrossStoreNodeEntityInstantiator.createEntityFromState(CrossStoreNodeEntityInstantiator.java:1) ...
I'm using a local database for now, but I'll need a remote server soon, so any feedback on this is greatly appreciated.
My setup:
spring-framework 3.0.7.RELEASE (several modules)
spring-data-neo4j 2.0.0.RELEASE (with cross-store support)
hibernate-core-3.6.9.GA
neo4j-1.6 (when using server, the server if the same version as the client libraries)
Exception occurs both on junit 4.9 and Tomcat 6.
Best regards,
Daniel


Reply With Quote
