I was looking for a fast way to map a java bean to an ldap entry and then I stumbled upon the ODM concept. It helped me to get a fast solution to my problem.
However after some tests of the CRUD features I spotted an issue with the update operation: I had an user entry in my ldap, this user was also member of several groups, then I tried to update a field of that user using the OdmManager.update method, the result was that the field was updated as expected, but then I checked the user's group membership and to my surprise it had been deleted.
From the OdmManager's update method default implementation (OdmManagerImpl.update) we can see:
The problem with this implementation is the call to the LdapTemplate's rebind method; that call will cause the entry being deleted first before replacing it with a new entry containing the changes. This implementation detail explains the behavior I describe above.Code:public void update(Object entry) { ... DirContextAdapter context = new DirContextAdapter(getId(entry)); mapToContext(entry, context); ldapTemplate.rebind(context); }
This behavior brings undesired side effects to the structure of other parts of the ldap. Wouldn't be better to implement the update method using LdapTemplate's modifyAttributes method?.
Best regards


Reply With Quote