Spring Data Neo4j - @RelationshipType 问题

2024-01-26

当关系类型用 a 注释时,我很难检索关系@RelationshipType field.

这些关系在 Neoclipse 中看起来正确,但我在应用程序中没有检索到任何结果。

不起作用的代码是(简化的):

@NodeEntity
public abstract class Entity {

    @RelatedToVia
    private Collection<Relationship> relationships;

    public Relationship relatedTo(Entity entity, String type) {
        Relationship relationship = new Relationship(type, this, entity);
        relationships.add(relationship);

        return relationship;
    }

    ...
}

and:

@RelationshipEntity
public class Relationship {

    @RelationshipType
    private String type;

    ...
 }

有效的代码是:

@RelationshipEntity(type = "something")
public class Relationship {

   ...
}

但是,这不适合我的用例(我有很多不同的Relationship任意组合之间的类型Entity实例。

完整的测试代码如下。Agency and Item都是子类Entity.

// Create first entity
Agency arnz = agencyRepository.save(new Agency());
arnz.setCode("ARNZ");
agencyRepository.save(arnz);

// Create second entity
Item r123 = itemRepository.save(new Item());
r123.setCode("R123");

// Create parent/child relationship between entities
r123.relatedTo(arnz, EntityRelationshipType.PARENT);
itemRepository.save(r123);

// Retrieve entity from database
Entity entity = itemRepository.findByCode("R123");

// Verify that relationship is present
assertThat(entity.getRelationships().iterator().hasNext(), is(true));

最后一行是测试失败的地方。有什么线索吗?

M

附言。我是 Neo4j 的业余爱好者,只是碰巧发现@RelationshipType,所以我很可能正在做一些可笑的错误。但愿如此!


很抱歉让您失望,但在检索过程中,代码现在不查找类型类,而是查找来自的类型@RelatedToVia or @RelationshipEntity或字段名称relationships作为关系类型。但你提出的观点是有道理的,你能在以下问题中提出问题吗?JIRA http://spring.neo4j.org/issues?

你有没有调查过template.getRelationshipsBetween ?

为什么不为你们的关系创建单独的课程呢?这种方法的用例是什么?

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring Data Neo4j - @RelationshipType 问题 的相关文章

  • Neo4j https 通信

    有没有办法只允许 https 而不是 http 与 Neo4j 服务器通信 另外 Neo4j Shell 的通信使用哪个通道 http 还是 https 这是来自 Neo4j 文档 HTTPS 支持 http docs neo4j org
  • Rails 3 和图形数据库

    在 Postgresql 上运行的 Rails 3 应用程序需要切换到图形数据库才能成长 它们有很多 并且都提供不同类型的 API 主要是 REST 我深受启发talks http nosql mypopescu com post 3429
  • 当属性名称为参数时如何查询属性值?

    通常我们可以查询属性值 例如 Match n Product where n name iPhone X return n 但是 就我而言 我不知道应该匹配哪个属性 但我只知道值 在这种情况下属性名称就变成了一种变量 我想要这样的东西 Ma
  • 如何从 py2neo 获取自动节点 ID?

    我正在使用 py2neo 3 1 2 版本和 Neo4j 3 2 0 我有一个问题 在 Neo4J 的 Web 界面上 我可以运行以下查询来获取节点 id MATCH n Person RETURN ID n 我想知道 py2neo API
  • “找不到类型的属性”组合存储库 spring-data-neo4j

    我在用着spring data neo4j我正在尝试组合存储库以便能够使用自定义存储库 我认为我已经正确遵循了中指定的命名约定20 8 7 创建存储库 http docs spring io spring data neo4j docs 3
  • 如何以最佳方式将 SQL 查询转换为 cypher?

    我是 neo4j 的新手 使用 3 0 版本 我有一个巨大的事务数据集 我将其转换为图形模型 我需要将下面的 SQL 查询转换为 cypher create table calc base as select a ticket id tic
  • Neo4JClient:如何创建关系?

    我看到了一篇具有相同标题的帖子 但不幸的是无法通过查看给定的示例找到解决方案 我通过以下方式创建了节点 private static void createExampleNetwork GraphClient client try Cyph
  • 在 Neo4j 中可视化连接的组件

    我可以使用下面的代码找到图中最密集连接的组件 CALL algo unionFind stream pnHours YIELD nodeId setId groupBy setId storing all node ids of the s
  • Neo4j 入门

    我对 neo4j 完全陌生 很抱歉问这样一个基本问题 我已经安装了 neo4j 我正在使用 shell localhost 7474 webadmin console 我正在寻找一个很好的示例 它使用一些 shell 命令从预先存在的图形数
  • Neo4j 2.0 唯一约束错误“节点已存在”,当它不存在时

    我在 Neo4j 唯一约束方面遇到了一些麻烦 其中 CREATE cypher 语句由于节点已经存在而无法执行 问题是 它不 存在 此外 昨天使用这些确切数据的精确流程也有效 我的neo4j版本是ubuntu 12 04 3上的commun
  • 如何将dbpedia导入neo4j? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我需要将 dbpedia 导入 neo4j 我从这里下载 dbpedia http wiki dbpedia org Download
  • 通过 awselb 使用 ssl 时的 neo4j java 驱动程序问题

    I am using neo4j community version 3 1 1 and enterprise edition version 3 0 1 with ssl configured through awselb To conn
  • 如何使用 nosql 构建成就和徽章

    我目前有一个使用 mongodb 作为数据库的社交游戏应用程序 我的问题是 如果我想创建一个积分和徽章系统 有哪些建议 成就 徽章的业务逻辑可能会变得非常复杂并且非常临时 因此实时授予徽章似乎效率不高 我想象将跟踪的操作添加到队列中的某处
  • 如何返回每个另一个节点属性的最大计数

    我需要计算一位作曲家的音乐作品每十年被演奏了多少次 然后只返回每十年演奏次数最多的一首作品 除了过滤除每十年最高计数之外的所有内容之外 该密码可以执行所有操作 match c Composer CREATED BY w Work lt 2
  • 参数映射不能用于 MERGE 模式

    我收到错误参数映射不能在合并模式中使用 我如何解决此错误 我正在使用下面的代码 我非常感谢任何帮助 提前致谢 MERGE u Person names RETURN u and data2 names name Keanu Reeves1
  • 同时运行 Gremlin-Server 和 NEO4J Server

    目前看来我们不能同时运行两者Neo4J服务器 and Gremlin服务器同时 有什么办法可以同时运行两者吗 NEO4J 正在运行 我尝试启动 Gremlin Server 然后出现以下错误 java lang RuntimeExcepti
  • 如何转储 neo4j 图形数据库?

    我将所有数据库存储在一个位置C JATIN DATA 数据库 neo4jDatabases 如何使用 neo4j Desktop 单独转储所有数据库 我已经尝试过 neo4j admin dump database to 这个命令但出现错误
  • with 子句做什么?新4j

    I don t understand what WITH clause do in Neo4j I read the The Neo4j Manual v2 2 2 http neo4j com docs stable query with
  • spring-data-neo4j 基本一对多关系不持久

    EDIT 示例项目可在github https github com troig neo4jCustomRepository 我在后端项目中使用 Neo4J Rest 图形数据库 托管在 grapheneDb 中 和 Spring Data
  • Cypher Neo4j 无法加载外部资源

    在 Windows 环境中 我尝试加载带有以下语句的 csv 文件 LOAD CSV WITH HEADERS FROM file E Neo4j customers csv AS row 它似乎无法正常工作并返回 无法加载外部资源 文件

随机推荐