简体   繁体   English

arangodb和spring数据,如何使用用户生成的ID?

[英]arangodb and spring data, how can I use a user generated Id?

I'm using ArangoDB arangodb-java-driver.version=4.2.1 and arangodb-spring-data.version=1.1.2 (although will be moving to spring boot 2 soon, so these will change) 我正在使用ArangoDB arangodb-java-driver.version = 4.2.1和arangodb-spring-data.version = 1.1.2(尽管很快就会迁移到Spring Boot 2,所以这些都会改变)

I would like to be able create new objects with an id that's already generated. 我希望能够使用已经生成的ID创建新对象。

I realize this can be done using the arangoTemplate/arangoOperations ( arangoOperations.insert(doc) ) but this takes us out of spring data and pulls arango specific code into my service classes. 我意识到可以使用arangoTemplate / arangoOperations( arangoOperations.insert(doc) )完成此操作,但是这使我们脱离了Spring数据,并将arango特定的代码拉入了我的服务类。

The issue is that if I save a new object that already contains an id (that uses the @Id annotation) then arango will assume it's an update, and fail with object-not-found (as it checks to see if the object is there before doing an update) 问题是,如果我保存一个已经包含ID(使用@Id批注)的新对象,则arango会假定它是一个更新,并且由于找不到对象而失败(因为它将检查该对象是否存在)在进行更新之前)

So ... does anyone have any bright ideas that will help me to use arangodb and spring data and provide my own IDs ? 那么...是否有人有什么聪明的主意可以帮助我使用arangodb spring数据提供自己的ID?

thanks in advance, 提前致谢,
Simon 西蒙

this is currently an issue and the only workaround I see, is to use a field annotated with @Key and use ArangoOperations.insert(Object) to initial save your entity. 目前这是一个问题,我看到的唯一解决方法是使用带有@Key注释的字段,并使用ArangoOperations.insert(Object)初始保存您的实体。

Solving this problem is on high priority. 解决此问题是当务之急。 I created a github issue to track the progress on this. 我创建了一个github问题来跟踪此进度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Spring Data中使用Pageable运行运行时生成的查询? - How can I run a runtime generated query with Pageable in Spring Data? 如何使用Spring Data MongoDB或Spring Data Jpa - How can I use Spring Data MongoDB or Spring Data Jpa 如何使Spring Data Couchbase保持id字段? - How can I make Spring Data Couchbase persist the id field? 我可以使用Spring数据jpa生成的存储库与@Query和继承策略=加入 - Can I use Spring data jpa generated repository with @Query and inheritance where strategy=joined 如何使用Wordpress在Spring Web应用程序中对用户进行身份验证? - How can I use Wordpress to authenticate a user in a spring web application? 如何访问 Java spring 中已登录用户的数据? - How can I access data of a logged in user in Java spring? 如何在Spring会话中存储每个用户数据? - How can I store per user data in Spring session? 如何检查Spring Data Cassandra Mapper生成的查询字符串 - How can I examine the query string generated by Spring Data Cassandra Mapper 如何将Spring Data Projection与Transient属性一起使用? - How can I use Spring Data Projection with a Transient property? 如何在 spring 数据 MongoDB 中使用 $where? - How can I use $where in spring data MongoDB?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM