【问题标题】:Spring data neo4j: No primary SDN label exists .. (i.e one with starting with _)Spring数据neo4j:不存在主要的SDN标签..(即以_开头的标签)
【发布时间】:2014-07-28 07:27:23
【问题描述】:

尝试在UserRepository extends GraphRepository<User> 上执行以下方法,但它抛出异常

@Query(
    "MERGE (user:User {appId:{0}, uid:{1}})" +
    "RETURN user"
)
public User createUserIfNotExists(String appId, String userId);

例外:

java.lang.IllegalStateException: No primary SDN label exists .. (i.e one with starting with _) 
at org.springframework.data.neo4j.support.typerepresentation.LabelBasedNodeTypeRepresentationStrategy.readAliasFrom(LabelBasedNodeTypeRepresentationStrategy.java:125)
at org.springframework.data.neo4j.support.typerepresentation.LabelBasedNodeTypeRepresentationStrategy.readAliasFrom(LabelBasedNodeTypeRepresentationStrategy.java:42)

但是将查询更改为"MERGE (user:_User 可以工作并将标签_User 应用于创建的节点。

Q1. 我可以告诉 SDN 仅附加 User 作为标签并避免使用 _User
Q2. 如果没有,那么我如何将 User_User 标签附加到所有用户节点。目前只贴_User标签


已编辑:

问题 1:

使用我以前的 SDN 版本(即 3.0.0.RELEASE),突然查询 user:User:_User 开始工作,但随后对于类似查询 song:Song:_SongSong 存储库失败,但适用于 song:_Songsong:Song

问题 2:

当我更新我的 SDN 或 Neo4j 版本时,我得到了奇怪的异常,这就是我没有更新我的 SDN 和 Neo4j 版本的原因。

刚才我将我的 SDN 更新为版本 3.1.1 并保持 neo4j 版本相同(即2.0.1),代码也相同,但随后出现以下异常

Exception in thread "main" java.lang.IllegalArgumentException: Environment must not be null!
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.data.repository.config.RepositoryConfigurationSourceSupport.<init>(RepositoryConfigurationSourceSupport.java:50)
at org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(AnnotationRepositoryConfigurationSource.java:74)
at org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:74)
at org.springframework.context.annotation.ConfigurationClassParser.processImport(ConfigurationClassParser.java:396)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:207)

在线ApplicationContext appCtx = new AnnotationConfigApplicationContext(ApplicationConfig.class);

【问题讨论】:

    标签: neo4j spring-data-neo4j


    【解决方案1】:

    它需要带有下划线的标签来识别 实际上属于这个类(在继承层次结构中)。

    迈克尔

    用途:

    MERGE (user:User:_User {appId:{0}, uid:{1}})
    RETURN user
    

    MERGE (user:User {appId:{0}, uid:{1}})
    ON CREATE SET user:_User
    RETURN user
    

    【讨论】:

    • 您使用的是哪个版本的 SDN/neo4j?我正在使用 SDN 3.1.1 和 Neo4j 2.1.2,它运行良好。
    • 3.0.0.RELEASE, 2.0.1
    • @MichaelHunger 我将我的 SDN 版本更新到 3.1.1 并遇到了另一个问题...我在我的问题中提到了这些问题(已编辑)
    • 尝试将 neo4j 更新到 2.1.2。
    • @YatendraGoel 升级到 spring 3.2.9.RELEASE,因为这是 SDN 使用的版本。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-08
    • 1970-01-01
    • 1970-01-01
    • 2020-12-13
    • 2017-02-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多