我通过REST使用SpringData和Neo4j,当我添加@Indexed(unique=true)时,我看到了一个异常。这不会在embedded中引发异常,如果删除unique=true,也不会在REST中引发异常。即使数据库为空(没有节点和索引),也会发生这种情况。
有什么想法吗?
package com.mycompany;
import org.springframework.data.neo4j.annotation.GraphId;
import org.springframework.data.neo4j.annotation.Indexed;
import org.springframework.data.neo4j.annotation.NodeEntity;
@NodeEntity
public class Person {
@GraphId
private Long id;
@Indexed(unique=true) private String name; // <<<-- does not error if I remove unique-true)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public int hashCode() {
int hash = 7;
hash = 23 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Person other = (Person) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
}
以下是异常跟踪:
java.lang.RuntimeException: Error adding element 10 className com.mycompany.Person to index __types__
at org.neo4j.rest.graphdb.ExecutingRestAPI.addToIndex(ExecutingRestAPI.java:397)
at org.neo4j.rest.graphdb.RestAPIFacade.addToIndex(RestAPIFacade.java:166)
at org.neo4j.rest.graphdb.index.RestIndex.add(RestIndex.java:60)
at org.springframework.data.neo4j.support.typerepresentation.AbstractIndexingTypeRepresentationStrategy.add(AbstractIndexingTypeRepresentationStrategy.java:123)
at org.springframework.data.neo4j.support.typerepresentation.AbstractIndexingTypeRepresentationStrategy.addToTypesIndex(AbstractIndexingTypeRepresentationStrategy.java:115)
at org.springframework.data.neo4j.support.typerepresentation.AbstractIndexingTypeRepresentationStrategy.writeTypeTo(AbstractIndexingTypeRepresentationStrategy.java:63)
at org.springframework.data.neo4j.support.mapping.TRSTypeAliasAccessor.writeTypeTo(TRSTypeAliasAccessor.java:46)
at org.springframework.data.neo4j.support.mapping.TRSTypeAliasAccessor.writeTypeTo(TRSTypeAliasAccessor.java:26)
at org.springframework.data.convert.DefaultTypeMapper.writeType(DefaultTypeMapper.java:199)
at org.springframework.data.convert.DefaultTypeMapper.writeType(DefaultTypeMapper.java:186)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityConverterImpl.write(Neo4jEntityConverterImpl.java:165)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister$CachedConverter.write(Neo4jEntityPersister.java:179)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.persist(Neo4jEntityPersister.java:243)
at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.persist(Neo4jEntityPersister.java:231)
at org.springframework.data.neo4j.support.Neo4jTemplate.save(Neo4jTemplate.java:294)
at org.springframework.data.neo4j.support.Neo4jTemplate.save(Neo4jTemplate.java:288)
at com.mycompany.NeoTest.testSomething(NeoTest.java:28)
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:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
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:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
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:236)
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)
为了完整起见,下面是测试代码:
package com.mycompany;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.neo4j.support.Neo4jTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import com.mycompany.Person;
import static org.junit.Assert.*;
@ContextConfiguration(locations = "classpath:testContext.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class NeoTest {
@Autowired
Neo4jTemplate template;
@Test
//@Transactional
public void testSomething() {
Person add = new Person();
add.setName("Jorgan Jorgansen");
add = template.save(add);
Person other = template.findOne(add.getId(), Person.class);
assertNotNull("Retrieved entity is non-null", other);
assertEquals("Retrieved entity equals saved entity", add, other);
}
}
似乎是一个已知的错误,请参阅此链接。无论如何,异常是关于__types__索引的,它与您在类中定义的索引无关,SDN使用它来按类名检索对象。
我的web-config.xml是
这是我要膨胀保存的axml文件 newstile.axml 和库存。 任何帮助都将不胜感激。提前谢谢你。这是调试中可能有用的部分
我在所有项目(平台共享)中将我的Xamarin. form包更新到最新(2.3.4.224),现在我似乎不应该再使用或枚举,因为它们已被弃用。 编译器因为这些行而抱怨: 上面写着: "Device.OS已过时。请改用Runtime平台" 到目前为止一切都很好,现在我想解决这个问题,我一直在尝试使用: 但它抛出了一个运行时异常。这是堆栈跟踪 04-08 14:57:34.812 I/MonoDroi
使用方法时激发了以下异常。应用程序的targetSDKVersion为21。 致命异常:主进程:app.rvamd.RecoverAllMyDeletedFile,PID:3700 java.lang.NoSuchMethodError:类landroid/support/v4/content/contextCompat中没有静态方法checkSelfPermission(landroid/con
出于日志记录的目的,我们正试图通过Spring自己的AOP捕获各种Spring的运行时异常,我必须说我没有成功,所以我非常感谢关于如何实现这一点的任何想法。 我试过这样的方法: 该类是自动代理的,并且方面类中的其余建议被正确地触发,因此必须有一个问题与AbulJ表达式。 更新:方法中的代码不运行,我不打算在通知中捕获异常。 有什么想法吗?Thx提前。 P.S.Spring框架版本为3.0.6。