springspring-dataspring-data-commons

What's the order of PersistentProperty instances are iterated over for a Spring Data PersistentEntity?


What is the access order of PersistentPropertys when iterating over them? Is it the same as in the definition of PersistentEntity, or is it random? I couldn't find any information about this in the Javadoc of Spring Data.


Solution

  • Fundamentally, the ultimate source of the properties created is Java's Class.getDeclaredFields() which doesn't guarantee any particular order. The high-level property creation algorithm can be found in AbstractMappingContext (ReflectionUtils.doWithFields(…) making the connection).

    I've filed and fixed a ticket in Spring Data Commons to clarify this in the Javadoc.