Skip to content

LDAP-305: Permit ODM to allow inheritance #340

Open
@spring-projects-issues

Description

@spring-projects-issues

Demétrius Jubé (Migrated from LDAP-305) said:

I was trying do use some inheritance when using ODM. Looking in the Internet, I found out this thread:
http://forum.spring.io/forum/spring-projects/data/ldap/129952-permit-odm-to-allow-inheritance

But I could not find anything here to make that modification, so I am opening an issue to it.

The solution Fneuch proposed was as follow:

Hi Guys,

First of all, sorry for any english mistake.

Secondly, is it me or ODM doesn't allow hierarchical inheritance? I've made a little change and it seems to work fine.

In the constructor of class ObjectMetaData I've replaced:

Code:

//Field[] fields = clazz.getDeclaredFields();

by

Code:

ArrayList<Field> fieldsTemp = new  ArrayList<>();
        fieldsTemp.addAll(Arrays.asList(clazz.getDeclaredFields()));
        Class<?> classTemp = clazz.getSuperclass();        
        while(!classTemp.equals(Object.class)) {
            fieldsTemp.addAll(Arrays.asList(classTemp.getDeclaredFields()));
          classTemp = classTemp.getSuperclass();            
        }
        // Get field meta-data - the @Attribute annotation
        Field[] fields = fieldsTemp.toArray(new Field[fieldsTemp.size()]);

Can you correct me here? Is there something that I didn't see? Because on create, find, delete I've seen no problem with my test... I didn't checkout project to made a full change, just replace the class in my own project for testing.

How can I ask for that feature in a future version? Thanks for any information!

Sylvain aka Fneuch

Activity

spring-projects-issues

spring-projects-issues commented on May 3, 2015

@spring-projects-issues
Author

daniel carter said:

This should be trivial to do by changing to use existing spring-framework utility methods. Then field behaviour will be the same as the rest of spring. Such a limitation that spring-ldap does not allow object-oriented programming

btocquec

btocquec commented on Jun 10, 2016

@btocquec

Hi,
Is there any chance to have this improvement added to a not-so-far release?
Please ... :/
Thanks

christophs78

christophs78 commented on Aug 9, 2018

@christophs78

Just run into this issue... 4 years later... still not fixed. :-(

Background: I have to implement a ldap-scheme which has common attributs. (each objectClass has a base of the same 3 attributes) Wanted to put this 3 attributes into a base class. And inhert the concrete classes (Person, OrgUnit, ...) from this.
Scheme: https://www.ref.gv.at/fileadmin/_migrated/content_uploads/LDAP-gv-at-teil1-2-3-0_2006-0221.pdf, Page 5 (2.4.2)

ricejamesh

ricejamesh commented on Dec 28, 2020

@ricejamesh

In the meantime, perhaps a comment in the @entry documentation stating that it doesn't support class inheritance. I've had the impression that I was doing something wrong in my project by using a class inheritance chain of customObject extends InterOrgPerson which extended OrganizationalPerson which extended Person. Until I read this post. A little comment in the @entry annotation saying that it will only reference the fields in the annotated class and excludes parent classes would have saved me a lot of head scratching. I also feel that JPA repositories do support inheritance which led me to believe this did also. At this point, cut-and-paste along with Lombok is the intermediate solution until something changes.

jtgasper3

jtgasper3 commented on Apr 21, 2021

@jtgasper3

Ran into this today. Rather annoying. Please at least add a note to the @entry docs as @ricejamesh suggested.

added a commit that references this issue on Nov 25, 2021
b009d28

10 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @rwinch@jtgasper3@jzheaux@btocquec@christophs78

    Issue actions

      LDAP-305: Permit ODM to allow inheritance · Issue #340 · spring-projects/spring-ldap