当我试图更新LdapRepository数据库中的现有对象时,Spring ()方法会抛出异常。
org.apache.directory.api.ldap.model.exception.LdapEntryAlreadyExistsException: ERR_250_ENTRY_ALREADY_EXISTS我应该使用什么方法来更新现有的ldap对象?
个人班:
@Entry(objectClasses = { "inetOrgPerson", "organizationalPerson", "person", "top" })
public class Person implements Serializable {
public Person() {
}
@Id
private Name dn;
@Attribute(name = "cn")
@DnAttribute(value = "cn")
@JsonProperty("cn")
private String fullName;
@Attribute(name = "uid")
private String uid;
private String mail;
@Attribute(name = "sn")
private String surname;
//setters and getters
}人员回购接口:
public interface PersonRepo extends LdapRepository<Person> {
}我就是这么更新人的:
personRepo.save(person);发布于 2015-10-23 18:50:41
Spring存储库的默认实现是SimpleLdapRepository,它检查带有@Id注释的属性,以确定对象是新的还是旧的,并执行更新。
当您试图执行更新时,我猜Person.dn是null。
您还可以通过实现org.springframework.data.domain.Persistable来控制这一点,并将您的逻辑放在isNew()方法中。
见实施细节。
https://stackoverflow.com/questions/33288011
复制相似问题