-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Introduce template method for easier customization of fragments #2202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can follow a simpler approach regarding Querydsl by providing a fragment interface that declares the methods as you wish including an implementation. Something along the lines of: interface MyQuerydslExtension<T> {
Page<T> findPage(Predicate predicate, Pageable pagable);
}
class MyQuerydslExtensionImpl<T> {
// …
} and on the actual repository: interface PersonRepository implements CrudRepository<Person, String>, QuerydslExecutor<Person>, MyQuerydslExtension<Person> {
} Spring Data's fragment scanning mechanism detects the |
@mp911de thanks for the quick answer. This is exactly what i tried, but then you cannot extend the This is not working
|
Ah, I see, you want to get hold of the Can you file a ticket in Spring Data Commons so we remove the |
I think that would help in my case. |
That's by design so we can freely update our implementation without the risk of breaking existing code. |
I am aware of the background. However, it would be very helpful for such adjustments. |
After careful reconsideration, we decided to revisit this topic. A lot of constructor arguments are hidden within |
@mp911de then maybe my PR is obsolet spring-projects/spring-data-commons#2360 |
Yeah, I think so. Also, the method name is a bit misleading so we want to rename In any case, thanks for your contribution. |
We introduced getRepositoryFragments(RepositoryMetadata,EntityManager,EntityPathResolver,CrudMethodMetadata) to easier get hold of typical arguments required for customization of repository base fragments that aren't bound to a specific entity type such as QuerydslJpaPredicateExecutor. Closes #2202.
With pleasure. |
Hello @mp911de are here any news? If not, could we remove the final from instantiateClass? |
I would like to write my own QueryDslExecutor to return a Slice instead of a Page e.g. Slice readAll. However, the QueryDslExecutor is hard coded in the factory.
In addition, there is no way to override the getTargetRepositoryViaReflection.
No member variable has a getter, so you have to rely entirely on reflection.
The (ugly) workaround looks like this
There should be an easier way to provide a custom executor.
The text was updated successfully, but these errors were encountered: