Skip to content
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

Jsonb support for Hibernate in spring boot 2.0.1 #11

Open
rtisma opened this issue Apr 12, 2018 · 2 comments
Open

Jsonb support for Hibernate in spring boot 2.0.1 #11

rtisma opened this issue Apr 12, 2018 · 2 comments

Comments

@rtisma
Copy link

rtisma commented Apr 12, 2018

Using spring boot 2.0.1 and following the instructions in the read me, the following error occurs

java.lang.AbstractMethodError: com.marvinformatics.hibernate.json.JsonUserType.nullSafeSet(Ljava/sql/PreparedStatement;Ljava/lang/Object;ILorg/hibernate/engine/spi/SharedSessionContractImplementor;)V

	at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:160)
	at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2715)
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3009)
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3533)
	at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:600)
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:474)

The simple fix is to just overload with the missing methods

public class CustomJsonType extends JsonUserType {

  public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
    return nullSafeGet(rs, names, (SessionImplementor) session, owner);
  }

  public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
    nullSafeSet(st, value, index, (SessionImplementor) session);
  }

}
@rtisma
Copy link
Author

rtisma commented Apr 12, 2018

version 4.0 depends on hibernate-core 4.2.21-Final, which does not have the SharedSessionContractImplementor class. Spring boot 2.0.1 uses hibernate-core 5.2.16-Final, and has this class

@velo
Copy link
Owner

velo commented Apr 12, 2018

This may be a good time to move from hibernate 4 to 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants