spring-projects / spring-data-jpa

Simplifies the development of creating a JPA-based data access layer.
https://spring.io/projects/spring-data-jpa/
Apache License 2.0
3.01k stars 1.42k forks source link

Visibility of `SimpleJpaRepository.ExampleSpecification` #3213

Closed dabico closed 1 year ago

dabico commented 1 year ago

Would it be possible to increase the visibility of SimpleJpaRepository.ExampleSpecification from private to protected? I'm developing a custom repository that extends SimpleJpaRepository, and would like to reuse this inner class as opposed to copying it from the parent. The class in question:

https://github.com/spring-projects/spring-data-jpa/blob/018c2acd86d0a901353036dcdf44eda0bc625bca/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java#L953-L987

gregturn commented 1 year ago

Fundamentally speaking, ExampleSpecification is an implementation detail to provide support for Query by Example.

I'd really to understand the use case you are attempting to solve that begs you to make changes and alterations to ExampleSpecification.

dabico commented 1 year ago

Hi @gregturn

In short, I wanted to create an extension to the Specification and Example query APIs to support Stream.

Here are the methods and signatures: https://github.com/seart-group/DL4SE/blob/274dbefd77f16b00cdace01d87a399a8308c7915/dl4se-server/src/main/java/ch/usi/si/seart/server/repository/support/JpaStreamExecutor.java

Here is the custom repository implementation: https://github.com/seart-group/DL4SE/blob/274dbefd77f16b00cdace01d87a399a8308c7915/dl4se-server/src/main/java/ch/usi/si/seart/server/repository/support/ExtendedJpaRepositoryImpl.java

I would not be making changes to the class itself, in fact, it can be final for all I care, so long as its visible and can be instantiated from this custom SimpleJpaRepository extension.

mp911de commented 1 year ago

Have you seen that you have all of this flexibility if you use the fluent findBy(Specification, q -> q.stream()) or findBy(Example, q -> q.stream()) API?

dabico commented 1 year ago

Have you seen that you have all of this flexibility if you use the fluent findBy(Specification, q -> q.stream()) or findBy(Example, q -> q.stream()) API?

HI @mp911de

I was not aware of this API, when was it introduced? I'm still on SB 2.7, and I don't think our organization will migrate to 3.X in the near future.

mp911de commented 1 year ago

It has been introduced with version 3.0. Spring Data JPA 2.7 has reached its OSS EOL by now (Nov 2023) and we will ship only one final OSS release. We generally avoid updates to API that has been released as changes to API that is available for quite a while asks for trouble.

Given that update, I'm closing the ticket.