diff --git a/src/main/java/com/samskivert/depot/impl/FieldMarshaller.java b/src/main/java/com/samskivert/depot/impl/FieldMarshaller.java index 00672cc..15f7bf0 100644 --- a/src/main/java/com/samskivert/depot/impl/FieldMarshaller.java +++ b/src/main/java/com/samskivert/depot/impl/FieldMarshaller.java @@ -7,6 +7,7 @@ package com.samskivert.depot.impl; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.nio.ByteBuffer; +import java.time.LocalDateTime; import java.util.Map; import java.sql.Blob; @@ -874,6 +875,19 @@ public abstract class FieldMarshaller @Override public String getColumnType (ColumnTyper typer, int length) { return typer.getTimestampType(length); } + @Override public void writeToObject (Object po, Object value) + throws IllegalArgumentException, IllegalAccessException { + // MySQL switched from using Timestamp for DATETIME fields to LocalDateTime; but we + // don't want to have to retroactively change a zillion lions of code, so we do the + // somewhat hacky thing here of converting a LocalDateTime into a Timestamp. + // Presumably any code that used Timestamp correctly did not assume that it had + // meaningful timezone information, and I hope no sane person is using a 20 year old + // Java persistence library for new code. + if (value instanceof LocalDateTime) { + value = Timestamp.valueOf((LocalDateTime)value); + } + _field.set(po, value); + } }). put(Blob.class, new ObjectMarshaller() { @Override public String getColumnType (ColumnTyper typer, int length) {