- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
背景
我的 spring data neo4j 应用程序给出了密码错误。
这很奇怪,因为我使用 neo ogm 来管理我所有的 cyper 语句,我自己没有编写任何 cypher。
这是我的错误:
CLI 输出中的密码错误
Error executing Cypher "Neo.ClientError.Statement.SyntaxError"; Code: Neo.ClientError.Statement.SyntaxError; Description: Invalid input '|': expected whitespace, comment, a relationship pattern, '.', node labels, '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, ',' or ']...
密码错误后 CLI 输出中出现 OGM 错误
...nested exception is org.neo4j.ogm.exception.CypherException: Error executing Cypher \"Neo.ClientError.Statement.SyntaxError\"; Code: Neo.ClientError.Statement.SyntaxError; Description: Invalid input '|': expected whitespace, comment, a relationship pattern, '...
在代码中定位错误发生的位置时出错 (GenericService)
...myproject.service.GenericService.find(GenericService.java:39) ~[classes/:na]...
GenericService第39行
Optional<T> object = getRepository().findById(id, depth);
我陷入困境
findById
在 springframework.data.neo4j.repository.Neo4jRepository.java 中声明为 Optional<T> findById(ID id, int depth);
自从我切换到 Spring data neo4j 5.0.0 以来,我最近开始使用 neo4jrepository 而不是 graphrepository。
所以,我想我已经在代码中找到了问题,但它不是我的代码,而是库,但我不能相信最新的 neo4j ogm 发布时存在 findById
中的错误功能。
问题
如何解决此密码错误?这个问题可能源自哪里?
更新1
我使用的是neo4j-ogm-version 3.0.0,spring-boot 2.0.0.M3,Neo4J是3.2.3,spring-data-neo4j 5.0.0.RELEASE,
更新2
难道我的id被实例化为Long
而 Neo4jRepository.java 已实例化为 ID
?
更多上下文
public T find(Long id) {
Optional<T> object = getRepository().findById(id, DEPTH_ENTITY);
if(object.isPresent())
return object.get();
return null;
}
更新3
springframework.data.neo4j.repository.Neo4jRepository.java包含
@NoRepositoryBean
public interface Neo4jRepository<T, ID extends Serializable> extends PagingAndSortingRepository<T, ID> {
<S extends T> S save(S s, int depth);
<S extends T> Iterable<S> save(Iterable<S> entities, int depth);
Optional<T> findById(ID id, int depth);
Iterable<T> findAll();
Iterable<T> findAll(int depth);
Iterable<T> findAll(Sort sort);
Iterable<T> findAll(Sort sort, int depth);
Iterable<T> findAllById(Iterable<ID> ids);
Iterable<T> findAllById(Iterable<ID> ids, int depth);
Iterable<T> findAllById(Iterable<ID> ids, Sort sort);
Iterable<T> findAllById(Iterable<ID> ids, Sort sort, int depth);
/**
* Returns a {@link Page} of entities meeting the paging restriction provided in the {@code Pageable} object.
* {@link Page#getTotalPages()} returns an estimation of the total number of pages and should not be relied upon for accuracy.
*
* @param pageable
* @return a page of entities
*/
Page<T> findAll(Pageable pageable);
/**
* Returns a {@link Page} of entities meeting the paging restriction provided in the {@code Pageable} object.
* {@link Page#getTotalPages()} returns an estimation of the total number of pages and should not be relied upon for accuracy.
*
* @param pageable
* @param depth
* @return a page of entities
*/
Page<T> findAll(Pageable pageable, int depth);
}
最佳答案
看来您对 Java 及其泛型类型不太熟悉。
让我们一步一步来:
例如,您需要定义一个实体
@NodeEntity
public class User {
@Id @GeneratedValue
private Long id;
...
然后定义一个从 SDN 扩展 Neo4jRepository 的存储库
public interface UserRepository extends Neo4jRepository<User, Long> {
}
通过这种方式,您可以通过指示您希望存储库来管理其身份由 Long
定义的 User
来专门化 Neo4jRepository
。Neo4jRepository
中定义的方法:
Optional<T> findById(ID id, int depth);
成为您存储库中的专用版本
Optional<User> findById(Long id, int depth);
您永远不会直接使用Neo4jRepository
,而只能使用您定义的子接口(interface)。
欲了解更多详情,请查看Spring Data commons reference 。还可以考虑看看 java 泛型类型。
更新
除了SDN的使用不正确之外,我认为错误的原因是你使用了Neo4j版本<3.1
我非常怀疑您正在使用评论中指定的 3.2.3。请仔细检查。
关于java - Spring 框架 Neo4jRepository 函数 findById 导致密码错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46652797/
我想从特定的本地对象中检索数据 var db=[ { "_id": "543adb9c7a0f149e3ac29438", "name": "user1", "email":
即使数据库中存在 id,以下 findById() 也会返回 null: router.get('/product/:id', function (req, res) { console.log("p
我有以下 dart 类,它加载一个对象和一个图像。当我执行热重载时,函数 findById 返回错误消息 Bad State: No element .在调试时,我看到我正在查询的列表是空的,一旦我进
我有运行 Mongoose 并成功返回以下结果的代码。 为什么我不能执行以下操作并从我的对象中获取值? Object.keys(result).forEach(function(record){
尝试使用 Axios.get 方法获取 ':id'S̶e̶r̶v̶e̶r̶̶i̶s̶̶r̶e̶s̶p̶o̶n̶d̶i̶n̶g̶̶w̶i̶t̶h̶̶a̶̶4̶0̶4̶ 目前我无法设置组件的状态。我得到一
hibernate 有一个特殊的问题。我有一个像这样的 hibernate 功能。 @SuppressWarnings("unchecked") public List findByResponseI
我在网上找到了以下代码,用于从数据库中获取对象。现在lock表示什么?什么时候锁? public T findById(ID id, boolean lock) { T entity;
我在使用 spring 3 和 hibernate-core 3.5.1-Final 的网络应用程序中遇到了一个非常奇怪的行为。 为了简单起见,我提供了我的代码.. if(ripid!=null){
我创建了 2 个表,名为:groupusermaps 和 groups。从 groupusermaps 中,我获取所有 groupId,并且这些 groupId 传入 findById() 方法,以获
我有三个实体。(我使用 xxx 作为这个例子的占位符) 我已经设置了他们所有的 @Entities与 @Entity @Table(name = "xxx") public class xxx { @
PHP 版本:5.2.17 CakePHP 版本:1.3.11 MySQL版本:5.5.9 我正在为客户开发一个非常简单的内部留言板网站。由于它仅供内部使用,因此客户要求没有用户名和密码,只有密码。没
我们有一个使用“findById”的非常简单的方法。 public Cart getCart(long cartId) { Cart cart = null; try {
我正在运行 Mongoose,我有一个工作连接,并且 findById()有时会返回结果: 情况1:无意义查询 models.Repo.findById("somefakeid", function(
列表项 var express = require("express"); var app = express(); var Mongoose = require("Mongoose"); Mongo
我正在尝试通过 mongodb 的对象 ID 获取项目对象,但是当我尝试在 postman 中调用该路由时,它会为我提供数据库中每个对象的列表(总共 4 个对象),而不是预期一个对象。 这是我为从数据
我有一个 Mongoose 模型,例如; var Schema = new Schema({ title: { type: String, required: true }, subtitle
我正在使用 mongoose 调用 findById,它没有返回所有字段,或者至少没有正确映射到字段。但如果我使用聚合,它会返回该字段 我有以下架构 const ratingSchema = new
我在使用 ButterKnife 时遇到此错误: error: cannot find symbol method findById(View,int) TextView tvHeaderTextOn
使用 Hibernate 获取的实体的所有字段都设置为 NULL。我怎样才能避免这种情况?这是我的 Jpa 存储库。 @Repository public interface PolicyReposi
我正在使用 Spring 和 JPA(带有 MySQL 的 Hibernate)以及 Lombok。 您好,我的实体的这一部分: @Data @AllArgsConstructor @NoArgsCo
我是一名优秀的程序员,十分优秀!