Cannot be transformed to Json object

See original GitHub issue

Hi all,

I’m using hibernate-types to serialize/deserialize list of my object with MySQL as below:

public class DefaultMessage {
    # few properties here with its getter/setter
}

public class Project {
    @Type(type = "json")
    @Column(name = "default_messages", columnDefinition = "json")
    private List<DefaultMessage> defaultMessages;

    # Getter/setter
}

Of course, I have defined map supper class and @TypeDef but it always return cannot be transformed to Json object.

Exception:

2018-05-29 19:00:10,343 WARN  [http-nio-8088-exec-4] ? (:) - The given string value: [B@4ad8cfea cannot be transformed to Json object
java.lang.IllegalArgumentException: The given string value: [B@4ad8cfea cannot be transformed to Json object
	at com.vladmihalcea.hibernate.type.util.ObjectMapperWrapper.fromString(ObjectMapperWrapper.java:52) ~[hibernate-types-52-2.2.1.jar:?]
	at com.vladmihalcea.hibernate.type.json.internal.JsonTypeDescriptor.fromString(JsonTypeDescriptor.java:87) ~[hibernate-types-52-2.2.1.jar:?]
	at com.vladmihalcea.hibernate.type.json.internal.JsonTypeDescriptor.wrap(JsonTypeDescriptor.java:110) ~[hibernate-types-52-2.2.1.jar:?]
	at com.vladmihalcea.hibernate.type.json.internal.AbstractJsonSqlTypeDescriptor$1.doExtract(AbstractJsonSqlTypeDescriptor.java:34) ~[hibernate-types-52-2.2.1.jar:?]
	at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:261) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:257) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:247) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:333) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2868) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1747) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1673) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.getRow(Loader.java:1562) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:732) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.processResultSet(Loader.java:991) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.doQuery(Loader.java:949) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.doList(Loader.java:2692) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.doList(Loader.java:2675) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.Loader.list(Loader.java:2502) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:392) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1490) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
	at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1463) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'B': was expecting ('true', 'false' or 'null')

Can you give me few suggestions to solve problem?

Thank you!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

12reactions
hamillercommented, Apr 28, 2021

Try to give your JsonB-Class an implements Serializable - at least that worked for me

6reactions
vladmihalceacommented, Apr 24, 2020

Hibernate Types does not require the Jackson Guava dependency. Your application needs it because you are using ImmutableMap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.IllegalArgumentException: The given string value ...
java.lang.IllegalArgumentException: The given string value: { "In last 7 days" : 19 } cannot be transformed to Json object · Ask Question.
Read more >
[SOLVED] Exception: Cannot convert string type to JSON object
It seems to be having a problem looking for a particular string, maybe the humidity part of the query?
Read more >
{"routingKey": "aaaa"} cannot be transformed to Json object
I try to save java object to json value in postgres as jsonb format, it works fine. But when try to query it,...
Read more >
How to use PostgreSQL's JSONB data type with Hibernate
You first have to create a Hibernate UserType, which maps the MyJson object into a JSON document and defines the mapping to an...
Read more >
java.lang .String cannot be converted into JSONObject
java.lang .String cannot be converted into JSONObject ... Hi i used this tutorial to insert data in my online server .it works fine...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found