PSQLException - spring boot 1.4.1 - spring data jpa - offsetdatetime/localdatetime identified as Bytestream

。_饼干妹妹 提交于 2020-01-04 02:30:06

问题


While integrating spring data JPA with postgres. I have a DB table representing the following java object.

private class A {

@Column(name="createdTime", columnDefiniton="TIMESTAMP WITH TIMEZONE")
OffsetDateTime dateTime;
}

I'm trying to save to this table, however, i am getting

Caused by: org.postgresql.util.PSQLException: ERROR: column "created_time" is of type timestamp with time zone but expression is of type bytea
  Hint: You will need to rewrite or cast the expression.
  Position: 131
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2182) ~[postgresql-9.4-1206-jdbc42.jar:9.4]
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1911) ~[postgresql-9.4-1206-jdbc42.jar:9.4]
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:173) ~[postgresql-9.4-1206-jdbc42.jar:9.4]
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:645) ~[postgresql-9.4-1206-jdbc42.jar:9.4]
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:495) ~[postgresql-9.4-1206-jdbc42.jar:9.4]
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:441) ~[postgresql-9.4-1206-jdbc42.jar:9.4]
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]

I did notice that postgres jdbc jar has 2 versions of AbstractJdbcStatement & AbstractJdbc42Statement. As postgresql-9.4-1206-jdbc42.jar:9.4 supports JDBC 4.2, im assuming calling the wrong class is causing this exception.


回答1:


Spring data jpa starter 1.4.1.RELEASE uses hibernate 5.0.11. overriding hibernate.version property to the latest version fixed the issues.



来源:https://stackoverflow.com/questions/40255521/psqlexception-spring-boot-1-4-1-spring-data-jpa-offsetdatetime-localdateti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!