-
Notifications
You must be signed in to change notification settings - Fork 30
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
allow multi-valued parameters to @Find & @Delete methods #553
base: main
Are you sure you want to change the base?
Conversation
(Rebased to pick up Otavio's changes .) |
After implementing this I decided that Therefore: 8b26ecb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about the possibility of doing something like this as well, but I didn't feel comfortable with adding it in version 1.0 because it has some overlap with the possibility of collection attributes in the future. I'll admit that I don't see use ever having an equals capability for collections, but I don't want to see the programming model be defined in an inconsistent way that we might later regret.
@njr-11 Read the way I've specified this more carefully. There's no ambiguity. If @Find Thing find(String[] field) is an equals-style condition, and this: @Find Thing find(String[][] field) is an We know the type of the entity field. |
Just to clarify, what is allowed in JPA is an So yes, we do need to cover this case. But it's covered :-) |
Rebased on main to pick up merged changes the repository interfaces. |
This proposal would have me doing something like, @Find
List<Product> sized(@By(_Product.SIZE) List<Size> sizes); versus what we might consider adding in the future, which could be something like, @Find
List<Product> sized(@By(_Product.SIZE) @In List<Size> sizes); The meaning of the latter is clearer. I might naturally read the former as looking for a product that is available in all of the sizes listed. The latter makes it clear that the product need only be available in any of the sizes in the list to match. Either way, we will eventually have a solution that we could put on BasicRepository.find/deleteByIdIn, so I would be okay with adding those methods now relying on Query by Method Name, and we can add annotations to them in the future. I do not want to add the multi-valued parameters in 1.0 because I expect we will regret it later. |
I mean, to me it's just unnecessarily more verbose. The meaning is already perfectly clear from the type of the parameter, and, in your code example, by the name of the parameter. I really don't see where the confusion could possibly arise. What I mean is, when I see this method signature: @Find
List<Product> sized(@By(_Product.SIZE) List<Size> sizes); I know exactly what it does and so do you. And so does everyone else, even Java developers who don't know Jakarta Data. Adding But, OK, let's say we aren't going to do this now. That's in principle completely fine by me. But then I insist we need to remove the methods of void deleteByIdIn(Iterable<K> ids);
Stream<T> findByIdIn(Iterable<K> ids); Now:
And the issue is that, as you showed the other day, we can't really come back and add these operations later because that would be a breaking change.
No, that doesn't work. Because |
(There's a third option, of course: we could solve the problem by going ahead and adding an |
Yes, good point. Somehow I managed to forget that we had removed the |
Yeah, to be clear, and it's totally my fault for not making this explicit in the issue description: I'm proposing this change now, rather than later, only because it's needed to rescue those methods of Otherwise this simply would not have come up. |
@Find
&@Delete
This change is completely obvious, now that it occurs to me.
And it leaves
existsById()
as the only method we can't currently define in terms of annotations.