Hello!
I'm running into a problem that seems exactly like bug DATAGRAPH-185 (Resolved in 2.1.M1) on spring-data-neo4j-2.1.0.BUILD-SNAPSHOT.
I have a graph structure where an Individual (node) is connected to 0 or more Events (node). Each Event is connected with a single Individual.
@NodeEntity
public class Individual
{
@GraphId
private Long id;
// Date of earliest occurring event of type BIRTH.
@Query(value = "start n=node({self}) match (n)-[:INDIVIDUAL_EVENT]->(event) where event.type = 'BIRTH' return event.date order by event.date desc limit 1")
private Date birthDate;
}
@NodeEntity
public class IndividualEvent
{
@GraphId
private Long id;
@Fetch
@RelatedTo(type="INDIVIDUAL_EVENT", direction = Direction.INCOMING)
private Individual individual;
private IndividualEventType type; // Enum
private Date date;
}When I create a new Individual and save it using
Individual ind = new Individual();
IndividualEvent birth;
if (webform.getBirthDate() != null)
{
birth = new IndividualEvent(IndividualEventType.BIRTH);
birth.setDate(webform.getBirthDate());
ind.addEvent(birth);
}
repos.save(ind); // This is IndividualService.java line 58I get the following exception and stack trace if I don't specify "birth" information (
webform.getBirthDate() == null).
java.util.NoSuchElementException: No element found in IteratorWrapper(empty iterator)
at org.neo4j.helpers.collection.IteratorUtil.assertNotNull(IteratorUtil.java:183)
at org.neo4j.helpers.collection.IteratorUtil.single(IteratorUtil.java:136)
at org.neo4j.helpers.collection.IteratorUtil.single(IteratorUtil.java:274)
at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.single(QueryResultBuilder.java:79)
at org.springframework.data.neo4j.fieldaccess.QueryFieldAccessorFactory$QueryFieldAccessor.executeQuery(QueryFieldAccessorFactory.java:113)
at org.springframework.data.neo4j.fieldaccess.QueryFieldAccessorFactory$QueryFieldAccessor.getValue(QueryFieldAccessorFactory.java:99)
at org.springframework.data.neo4j.fieldaccess.DefaultEntityState.getValue(DefaultEntityState.java:97)
at org.springframework.data.neo4j.support.mapping.SourceStateTransmitter.copyEntityStatePropertyValue(SourceStateTransmitter.java:110)
at org.springframework.data.neo4j.support.mapping.SourceStateTransmitter.access$000(SourceStateTransmitter.java:39)
at org.springframework.data.neo4j.support.mapping.SourceStateTransmitter$1.doWithPersistentProperty(SourceStateTransmitter.java:57)
at org.springframework.data.neo4j.support.mapping.SourceStateTransmitter$1.doWithPersistentProperty(SourceStateTransmitter.java:54)
at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:173)
at org.springframework.data.neo4j.support.mapping.SourceStateTransmitter.copyPropertiesFrom(SourceStateTransmitter.java:54)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityConverterImpl.loadEntity(Neo4jEntityConverterImpl.java:98)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityConverterImpl.read(Neo4jEntityConverterImpl.java:90)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister$CachedConverter.read(Neo4jEntityPersister.java:168)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.createEntityFromState(Neo4jEntityPersister.java:186)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.persist(Neo4jEntityPersister.java:239)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.persist(Neo4jEntityPersister.java:227)
at org.springframework.data.neo4j.support.Neo4jTemplate.save(Neo4jTemplate.java:295)
at org.springframework.data.neo4j.repository.AbstractGraphRepository.save(AbstractGraphRepository.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:323)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:308)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
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:202)
at $Proxy26.save(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy28.save(Unknown Source)
at dixon.service.IndividualService.createNewUnconnectedIndividual(IndividualService.java:58)
// Spring MVC calls before this point.
I don't get the exception and the application works as expected if I specify "birth" information
(webform.getBirthDate()!= null)
Any ideas?
Thanks in advance.