You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today when using @ValueConverter to convert a field customly, I found that spring-data-elasticsearch will invoke PropertyValueConverter#write twice if query return a Stream or Collection in this method.
public interface SampleRepository extends ElasticsearchRepository<Sample, String> {
Stream<Sample> findBySomeField(String someField);
// this method uses findAllBy to just avoid duplicate with findBy in the last method
List<Sample> findAllBySomeField(String someField);
Sample findSampleBySomeField(String someField);
}
If the query parameter is what,
the first method will generate the query as:
puppylpg
changed the title
Stream/Collection query criteria is converted twice wrongly for custom @ValueConverter
query criteria is converted twice wrongly for custom @ValueConverterOct 18, 2022
Today when using
@ValueConverter
to convert a field customly, I found that spring-data-elasticsearch will invokePropertyValueConverter#write
twice if query return aStream
orCollection
in this method.For example, using this entity(I renamed it as
Sample
, and defined prefix asfoo_
) and custom FooConverter, and create a repository class:If the query parameter is
what
,the first method will generate the query as:
the prefix
foo_
will be added twice so the query string becomes intofoo_foo_what
.The second and the third do the same:
also as
foo_foo_what
.If prefix is
foo-
as the post wrote originally, the query is stranger:the query string becomes
foo\\-foo\\-what
, not only doublefoo-
, but also add slashes asfoo\\-
.I think converting query criterias once should be as expected, rather than twice.
The text was updated successfully, but these errors were encountered: