【发布时间】:2016-05-02 20:20:27
【问题描述】:
根据migration of SDN (Spring-data-neo4j) v3 to SDN4,索引不再存在,因此预计这将不再起作用。
@NodeEntity
public class User extends Unversioned{
@Indexed(unique=true,failOnDuplicate = true) // <-- THIS
private String login;
...
}
根据here 或there,似乎没有人感到惊讶。这不是在模型本身上定义约束的“点”吗?
Sring-data主页定义的任务:
Spring Data 的使命是为数据访问提供熟悉且一致的基于 Spring 的编程模型,同时仍保留底层数据存储的特殊特性。
即使与the latest Spring-data-JPA official example 相比,模型上仍然定义了约束:
@Entity
public class Customer extends AbstractEntity {
private String firstname, lastname;
@Column(unique = true)
private EmailAddress emailAddress;
在我看来,允许在非常基于 java 的模型上定义约束似乎是更不容易出错的系统。 如果模型和约束是解耦的,我们应该如何建立一个一致的模型?我错过了什么?
【问题讨论】:
标签: spring-data spring-data-neo4j spring-data-neo4j-4