[英]LdapRepository update spring-ldap
當我嘗試更新LDAP數據庫中的現有對象時,Spring LdapRepository save()方法將引發異常。
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);
Spring LDAP存儲庫的默認實現是SimpleLdapRepository ,它檢查帶有@Id
注釋的屬性,以確定對象是新對象-並執行創建還是舊操作 -並執行更新。
我猜您嘗試執行更新時Person.dn
為null
。
您還可以通過實現org.springframework.data.domain.Persistable
對此進行控制,並將邏輯放在isNew()
方法中。
請參閱實現細節 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.