-
Notifications
You must be signed in to change notification settings - Fork 358
Converter<String, …>
is applied to derived query
#1682
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
This is expected behavior and should have had never worked otherwise. By specifying a Derived queries have an association to the property that is being queried. You can bypass the converter on the query side by providing a custom query, such as |
Converter<String, …>
is applied to derived query
While this converter setup is indeed "interesting", I think this is actually a duplicate of #1681 |
Indeed my issue is related to #1681, and your fix solves my issue as well. record JsonbValue(String value) {}
@ReadingConverter
class JsonbValueReadingConverter implements Converter<PGobject, JsonbValue> {
@Override
public JsonbValue convert(@NonNull PGobject source) {
if (source.getValue() == null) {
return null;
}
return new JsonbValue(source.getValue());
}
}
@WritingConverter
class JsonbValueWritingConverter implements Converter<JsonbValue, PGobject> {
@Override
public PGobject convert(@NonNull JsonbValue source) {
var pGobject = new PGobject();
pGobject.setType("jsonb");
try {
pGobject.setValue(source.value());
} catch (SQLException e) {
throw new IllegalStateException(e);
}
return pGobject;
}
} This should be more robust and it doesn't require adding Thank you for the clarification! |
Hi, maintainers!
I started my upgrade to spring data jdbc 3.2.0 and found an issue with my setup. I've got a postgresql database and some tables with
jsonb
type which are converted to simple strings in my entities. To achieve this, I created a pair ofConverter
s. The code is pretty straitforward:With them, I could use
String
s in my entities both asvarchar
orjsonb
up until 3.1.6 but it broke with 3.2.0. To better illustrate it I created a reproducer here.I'm not sure whether it's a regression, or I just misused an existing API. Could you help me out here?
The text was updated successfully, but these errors were encountered: