AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-17017525

it_would_be_better's questions

Martin Hope
it_would_be_better
Asked: 2024-11-15 21:34:12 +0800 CST

Spring Data Neo4j:当使用枚举作为@Node时,findAll 失败并显示“未找到必需属性 $enum$name”

  • 5

我正在使用 Spring Data Neo4j 来处理我的 Neo4j 数据库。我的应用程序包含一个与名为 Type 的枚举有关系的 Variation 节点实体。这是我的代码的简化版本:

@Node
public class Variation extends BaseEntity {
    private String title;

    @Relationship(type = "HAS_ATTRIBUTE", direction = Relationship.Direction.OUTGOING)
    private Type type;

    // Other fields and relationships...
}
@Node
public enum Type {
    CUSTOM(0),
    FIX(1),
    // Other constants...

    @Id
    private final int id;

    Type(int id) {
        this.id = id;
    }
}

这是我的build.gradle依赖项:

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-neo4j'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

    implementation 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
}

我还使用 VariationService 创建节点和关系。VariationRepositoryfindAll上的方法失败,并出现以下错误:

java.lang.IllegalStateException: Required property $enum$name not found for class org.com.example.node.Type
    at org.springframework.data.mapping.PersistentEntity.getRequiredPersistentProperty
    ...

该错误似乎表明类型枚举映射存在问题。

我的问题是:

  • 如何配置 Spring Data Neo4j 以将 Type 等枚举正确映射为节点?
  • 使用 Spring Data 时,是否有特定的方法来处理 Neo4j 中的枚举属性?
java
  • 1 个回答
  • 21 Views
Martin Hope
it_would_be_better
Asked: 2024-11-02 00:38:31 +0800 CST

Neo4j 中同一查询的执行时间各不相同

  • 5

我在 Neo4j 中运行相同的查询,并注意到执行时间差异很大。例如,查询可能在 5-6 秒内执行,而有时则需要 2-3 分钟,即使数据保持不变。

:param {
  idsToExclude: []
};

:auto LOAD CSV WITH HEADERS FROM ('file:///PERSON_DATA.csv') AS row
WITH row
WHERE NOT row.`person_id` IN $idsToExclude AND NOT row.`person_id` IS NULL
CALL {
  WITH row
  MERGE (n: `Person` { `person_id`: row.`person_id` })
  SET n.`person_id` = row.`person_id`
  SET n.`name` = row.`name`
  SET n.`age` = toInteger(row.`age`)
  SET n.`email` = row.`email`
  SET n.`address` = row.`address`
  SET n.`creation_date` = datetime(row.`creation_date`)
  SET n.`last_modified_date` = datetime(row.`last_modified_date`)
} IN TRANSACTIONS OF 5000 ROWS;

这是我的配置文件中的一些数据,如果需要的话,这些数据已被取消注释

server.memory.heap.initial_size=8G
server.memory.heap.max_size=16G
dbms.memory.transaction.total.max=32G

解释我的查询

第一部分 第二部分 第二部分

为什么在 Neo4j 中执行相同的查询会花费不同的时间?哪些因素会影响这一点,以及如何优化其性能?

neo4j
  • 1 个回答
  • 26 Views
Martin Hope
it_would_be_better
Asked: 2024-10-08 17:24:00 +0800 CST

执行查询时,并非所有影响关系都会添加到 Neo4j 中

  • 6

我的数据库: 我的 Neo4J 数据库

我正在使用 Neo4j 数据库,并尝试在 Issue 节点和 Version 节点之间创建 :Impact 关系,这些关系从 firstAffected 到 fixedVersion。但是,从结果可以看出,并非所有关系都已创建。

这是我的疑问:

MATCH (issue:Issue {name: "Issue 1"})  
MATCH (firstAffected:Version)<-[:First_Affected]-(issue), (fixedVersion:Version)<-[:Fixed]-(issue)  
WITH fixedVersion, firstAffected, issue  
MATCH path = (firstAffected)<-[:NEXT_VERSION*]-(fixedVersion)  
WITH nodes(path) AS allNodes, issue  
WITH allNodes[..-1] AS impact_target_nodes, issue  
UNWIND impact_target_nodes AS targetNode  
CREATE (issue)-[:Impact]->(targetNode)

查询没有将影响关系添加到版本 7。我预计路径中的所有版本都将链接到问题,但事实并非如此。

如何修改查询以正确创建 firstAffected 和 fixedVersion 之间所有版本的影响关系?

database
  • 1 个回答
  • 23 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve