I use java, apache-cayenne and postgreSQL.
My app works fine on desktop, but I get an error when I run it on Heroku:
org.postgresql.util.PSQLException: Bad value for type timestamp/date/time:
{1}
there are also warnings:
INFO org.apache.cayenne.log.JdbcEventLogger - --- transaction started.
WARN org.apache.cayenne.access.types.SerializableTypeFactory - Haven't found suitable ExtendedType for class 'java.time.LocalDate'. Most likely you need to define a custom ExtendedType.
WARN org.apache.cayenne.access.types.SerializableTypeFactory - SerializableType will be used for type conversion.
INFO org.apache.cayenne.log.JdbcEventLogger - --- transaction started.
INFO org.apache.cayenne.log.JdbcEventLogger - SELECT t0.DATE, t0.ROOM, t0.TIME, t0.TYPE, t0.PROFESSOR_ID, t0.SUBJECT_ID, t0.LESSON_ID FROM Lesson t0 JOIN Subject t1 ON (t0.SUBJECT_ID = t1.SUBJECT_ID) WHERE (t0.DATE = ?) AND (t1.USER_ID = ?) [bind: 1->DATE:2017-12-08, 2->USER_ID:81627965]
Here is my xml:
<db-entity name="Lesson">
<db-attribute name="DATE" type="DATE"/>
<db-attribute name="LESSON_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
<db-attribute name="PROFESSOR_ID" type="INTEGER"/>
<db-attribute name="ROOM" type="VARCHAR" length="50"/>
<db-attribute name="SUBJECT_ID" type="INTEGER"/>
<db-attribute name="TIME" type="TIME"/>
<db-attribute name="TYPE" type="INTEGER"/>
</db-entity>
<obj-entity name="Lesson" className="com.intetics.organizerbot.entities.Lesson" dbEntityName="Lesson">
<obj-attribute name="date" type="java.time.LocalDate" db-attribute-path="DATE"/>
<obj-attribute name="room" type="java.lang.String" db-attribute-path="ROOM"/>
<obj-attribute name="time" type="java.time.LocalTime" db-attribute-path="TIME"/>
<obj-attribute name="type" type="int" db-attribute-path="TYPE"/>
</obj-entity>
I work with the same Heroku Postgres database from desktop and Heroku.
It seems there is some problem connected with LocalDate class. But I have no idea why everything works fine on my computer, while there are problems on heroku.
I also tried to deploy jar which worked fine and it still doesn't work.
Do you have any idea on why this happens and how can I fix it?
Simular question wath asked about production server Bad value for type timestamp on production server but I doesn't seem I can apply it's answers on Heroku.
In order to use Java 8
java.time.*
classes from Cayenne you need to make sure you include cayenne-java8 module to your project, see this docs for details. Without it Cayenne just don't know how to handle those classes.