micronaut-data
micronaut-data copied to clipboard
Docs on `@Where` seem to point to wrong parameter format
Hello,
Quick one, I think!
Micronaut-Data-Model 2.3.1, JDK 11 (the docs seem the same in master) read
* <p>Parameterized variables can be specified using the dollar syntax: {@code book_.enabled = ${enabled}}. In
* this case the parameter must be declared in the method signature a compilation error will occur.</p>
If I do
@Repository
@Slf4j
@Where("@.accountId = ${accountId}")
public abstract class MyRepo implements CrudRepository<MyRecord, UUID> {
yields
io.micronaut.context.exceptions.ConfigurationException: Could not resolve placeholder ${accountId}
I went and looked at the tests for the annotation, and they suggest it should be :accountId
I tried this and it works†. Are the docs off?
Thanks!
† of course it doesn't actually 'work' since the autogeneration of findById
, existsById
and deleteById
now fail but that's a different problem.
Yeah that’s not correct, you can move the annotation to the methods you want to have that
Thanks for the quick reply @dstepanov !
To be clear (and this is pseudocode),
@Repository
public abstract class MyRepo implements CrudRepository<MyRecord, UUID> {
@Where("@.accountId = ${accountId}")
public abstract MyRecord findByMyIdAndAccountId(final UUID myId, final String accountId);
}
Returns
Could not resolve placeholder ${accountId}
io.micronaut.context.exceptions.ConfigurationException: Could not resolve placeholder ${accountId}
at io.micronaut.context.env.DefaultPropertyPlaceholderResolver$PlaceholderSegment.getValue(DefaultPropertyPlaceholderResolver.java:260)
as well, but using :accountId
instead of ${accountId}
makes the tests pass.
This remains not a valid use case because @Where
doesn't seem to add anything here because the dynamic method generation is already doing the right thing. Still... It still seems like the ${}
syntax might be a documentation error.
Using ${}
is a documentation error.
@dstepanov this issue seems fixed, as I can't find any ${}
in the docs