spring-data-commons icon indicating copy to clipboard operation
spring-data-commons copied to clipboard

Introduce first-class type-safe property path references at the core level

Open mp911de opened this issue 2 months ago • 0 comments

We now support type-safe property paths and property references:

Java variants:

PropertyPath.from("name", Person.class) // existing String-based API
PropertyPath.of(Person::getName) // type-safe property reference expression

PropertyPath.from("address.country", Person.class) // existing nested path API
PropertyPath.of(Person::getAddress).then(Address::getCountry) // type-safe composed path expression


PropertyReference.of(Secret::getSecret)

Kotlin variants:

PropertyReference.of(Secret::secret)

PropertyPath.of(Person::address / Address::city)

allowing type-safe usage through e.g.:

Sort.by(Person::getFirstName, Person::getLastName)

Module adoption:

  • [ ] https://github.com/spring-projects/spring-data-jpa/pull/4086
  • [ ] MongoDB
  • [ ] Relational
  • [ ] https://github.com/spring-projects/spring-data-cassandra/pull/1626

mp911de avatar Nov 17 '25 10:11 mp911de