簡體   English   中英

LdapRepository更新spring-ldap

[英]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.dnnull

您還可以通過實現org.springframework.data.domain.Persistable對此進行控制,並將邏輯放在isNew()方法中。

請參閱實現細節

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM