Preconditions:
a. There is an attributetype in ldap schema - e.g. 'someAttribute'.
b. The type is mentioned in the MAY list of an objectClass - e.g. 'someClass'.
c. There is an ODM entry class mapped to the objectClass.
Steps to reproduce:
Create an entry and fill it in including a value for 'someAttribute'.
Save it - odmManager.create(entry);
Result: the entry is in DIT, 'someAttribute' exists and filled.
Update the entry: set null as a new value for 'someAttribute' property.
Save it - odmManager.update(entry);
Actual Result: the entry is in DIT, 'someAttribute' exists and its value the same as in p.2.
Expected Result: the entry is in DIT but without 'someAttribute'.
Note:
I've looked through OdmManagerImpl source code and found out that before actual update is executed the method OdmManagerImpl#mapToContext(Object,DirContextOperations) is invoked. The method converts Java representation of an Ldap Entry. During the conversion only non-nullable properties of an entry are considered, null field values are ignored at all:
if (!attributeInfo.isList()) {
// Single valued - get the value of the field
Object fieldValue = field.get(entry);
// Ignore null field values
if (fieldValue != null) {
// 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));
}
}
Migrated from LDAP-271
Hi. I've faced with a problem using ODM.
Preconditions: a. There is an attributetype in ldap schema - e.g. 'someAttribute'. b. The type is mentioned in the MAY list of an objectClass - e.g. 'someClass'. c. There is an ODM entry class mapped to the objectClass.
Steps to reproduce:
Actual Result: the entry is in DIT, 'someAttribute' exists and its value the same as in p.2.
Expected Result: the entry is in DIT but without 'someAttribute'.
Note: I've looked through OdmManagerImpl source code and found out that before actual update is executed the method OdmManagerImpl#mapToContext(Object,DirContextOperations) is invoked. The method converts Java representation of an Ldap Entry. During the conversion only non-nullable properties of an entry are considered, null field values are ignored at all: if (!attributeInfo.isList()) { // Single valued - get the value of the field Object fieldValue = field.get(entry); // Ignore null field values if (fieldValue != null) { // 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)); } }
Many Thanks, Vadzim