属性未映射到条目

时间:2018-06-11 08:13:52

标签: spring-ldap

我有这个条目,但在调用ldapTemplate.findAll(PersonEntry.class)时,该字段始终为null @Attribute(name =" hsaIdentity") private String hsaIdentity;

ldiff包含

dn:cn = John Doe,ou =开发,ou = IT,ou = Departments,dc = example,dc = com objectclass:顶部 对象类:人 objectclass:organizationalPerson objectclass:inetOrgPerson employeeNumber:1 mail:john.doe@example.com cn:John Doe givenName:约翰 sn:Doe 职称:高级程序员 电话号码:+46 555-12345 hsaIdentity:hsaIdentity

package se.sll.common.person.domain;

import org.springframework.ldap.odm.annotations.Attribute;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;
import se.sll.common.AbstractEntry;
import se.sll.common.BaseBuilder;
import util.ReflectionBasedToStringBuilder;
import javax.naming.Name;
@Entry(objectClasses = {"inetOrgPerson", "organizationalPerson", "person","top"}, base = "ou=Departments")
public final class PersonEntry extends AbstractEntry {

@Id
private Name id;

@Attribute(name = "cn")
private String fullName;

@Attribute(name = "employeeNumber")
private int employeeNumber;

@Attribute(name = "givenName")
private String firstName;

@Attribute(name = "sn")
private String lastName;

@Attribute(name = "title")
private String title;

@Attribute(name = "mail")
private String email;

@Attribute(name = "telephoneNumber")
private String phone;

@Attribute(name = "hsaIdentity")
private String hsaIdentity;

public PersonEntry() {
}

public PersonEntry(Builder builder) {
    this.hsaIdentity = builder.hsaIdentity;
    this.phone = builder.phone;
    this.email = builder.email;
    this.title = builder.title;
    this.lastName = builder.lastName;
    this.firstName = builder.firstName;
    this.fullName = builder.fullName;
    this.employeeNumber = builder.employeeNumber;
}

public HsaId getId() {
    return HsaId.builder().withValue(hsaIdentity).build();
}

public String getFullName() {
    return fullName;
}

public int getEmployeeNumber() {
    return employeeNumber;
}

public String getFirstName() {
    return firstName;
}

public String getLastName() {
    return lastName;
}

public String getTitle() {
    return title;
}

public String getEmail() {
    return email;
}

public String getPhone() {
    return phone;
}


@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    PersonEntry user = (PersonEntry) o;

    if (id != null ? !id.equals(user.id) : user.id != null) return false;

    return true;
}

@Override
public int hashCode() {
    return id != null ? id.hashCode() : 0;
}

@Override
public String toString() {
    return ReflectionBasedToStringBuilder.toString(this);
}

public static Builder builder() {
    return new Builder();
}

public static class Builder implements BaseBuilder<PersonEntry> {
    private String hsaIdentity;
    private String fullName;
    private int employeeNumber;
    private String firstName;
    private String lastName;
    private String title;
    private String email;
    private String phone;


    public Builder withFullName(String fullName) {
        this.fullName = fullName;
        return this;
    }

    public Builder withId(String hsaIdentity) {
        this.hsaIdentity = hsaIdentity;
        return this;
    }

    public Builder withFirstName(String firstName) {
        this.firstName = firstName;
        return this;
    }

    public Builder withLastName(String lastName) {
        this.lastName = lastName;
        return this;
    }

    public Builder withTitle(String title) {
        this.title = title;
        return this;
    }

    public Builder withEmail(String email) {
        this.email = email;
        return this;
    }

    public Builder withPhone(String phone) {
        this.phone = phone;
        return this;
    }

        public Builder withEmployeeNumber(int employeeNumber) {
            this.employeeNumber = employeeNumber;
            return this;
        }

        public PersonEntry build() {
            return new PersonEntry(this);
        }
    }
}

0 个答案:

没有答案