Skip to content

Converter<String, …> is applied to derived query #1682

@genuss

Description

@genuss

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 of Converters. The code is pretty straitforward:

@ReadingConverter
class StringJsonbReadingConverter implements Converter<PGobject, String> {

  @Override
  public String convert(@NonNull PGobject source) {
    if (source.getValue() == null) {
      return null;
    }
    return source.getValue();
  }
}

@WritingConverter
class StringJsonbWritingConverter implements Converter<String, PGobject> {

  @Override
  public PGobject convert(@NonNull String source) {
    var pGobject = new PGobject();
    pGobject.setType("jsonb");

    try {
      pGobject.setValue(source);
    } catch (SQLException e) {
      throw new IllegalStateException(e);
    }

    return pGobject;
  }
}

With them, I could use Strings in my entities both as varchar or jsonb 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions