Lob Coulmn to use in JPA Specification on Criteria builder

204 views Asked by At
    @Lob
    @Column(name = "message")
    private String message;

Above property in an Entity, which is a blob data type in the Postgres database, it stores as bigint(byte location, I guess in db) in table.

I have written JPA specification for the entity with all the property which works properly.

if (!StringUtils.isEmpty(criteria.getMessage())) {
            predicateList.add(cb.like(root.get("message"), "%" + criteria.getMessage() + "%"));
            isFilterEmpty = false;
   }

above code is a specification impl on the message property in the table, since bigint is stored in the table, specification query does not convert bigint to text(lo_get posgres method to convert to original text value), it uses bigint value itself to compare on like, so it throws an error.

Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: text ~~ bigint
  Hint: No operator matches the given name and argument types. You might need to add explicit type casts.

How to address this issue? Temporarily I have not added this filter in the specification, after data fetch, I have impl to filter based on message

0

There are 0 answers