diff --git a/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java b/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java index acfb7bd3..c0930d35 100644 --- a/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java +++ b/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java @@ -228,6 +228,8 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { // Convert the field value to the required type and write it into the JNDI context context.setAttributeValue(attributeInfo.getName().toString(), converterManager.convert(fieldValue, attributeInfo.getSyntax(), targetClass)); + } else { + context.setAttributeValue(attributeInfo.getName().toString(), null); } } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithNoDnAnnotationsITest.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithNoDnAnnotationsITest.java index 3f4969dc..cc311c61 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithNoDnAnnotationsITest.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithNoDnAnnotationsITest.java @@ -31,6 +31,7 @@ import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.springframework.ldap.query.LdapQueryBuilder.query; @@ -164,4 +165,21 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat assertTrue(true); } } + + /** + * Test case for Jira LDAP-271. + */ + @Test + public void testLdap271() { + Person person = tested.findOne(query() + .where("cn").is("Some Person3"), Person.class); + + // Perform test + person.setTelephoneNumber(null); + tested.update(person); + + person = tested.findOne(query() + .where("cn").is("Some Person3"), Person.class); + assertNull("TelephoneNumber should be null", person.getTelephoneNumber()); + } }