0

i have generated o jhipster project using a jdl file (with filters):

entity MyEntity {
    name String,
    content String
}

In @Entity class, I modified the "content" attribute to have a json column in the database

@Type(type = "jsonb")
@Column(columnDefinition = "jsonb")
private String content;

When I try to filter by the content of the "content" field I get this error:

Caused by: java.lang.IllegalArgumentException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('%' (code 37)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"%valuetofind%"; line: 1, column: 2]
    at com.vladmihalcea.hibernate.type.util.ObjectMapperWrapper.toJsonNode(ObjectMapperWrapper.java:92)
    at com.vladmihalcea.hibernate.type.json.internal.JsonTypeDescriptor.unwrap(JsonTypeDescriptor.java:129)
    at com.vladmihalcea.hibernate.type.json.internal.JsonBinarySqlTypeDescriptor$1.doBind(JsonBinarySqlTypeDescriptor.java:25)
    at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:73)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:276)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:271)
    at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:53)
    at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:682)
    at org.hibernate.loader.Loader.bindPreparedStatement(Loader.java:2150)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2127)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2059)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037)
    at org.hibernate.loader.Loader.doQuery(Loader.java:956)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357)

I don't understand why the % is added

1
  • 1
    1) You need to add the query you tried as update to question. 2) This %valuetofind%" would seem to indicate you did something similar to ... <some_field> like %valuetofind%. Mar 1 at 16:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy