Repository navigation
Closed
Labels
Description
environment
jasync-r2dbc-mysql version: 1.1.7
<!-- r2dbc mysql -->
<dependency>
<groupId>com.github.jasync-sql</groupId>
<artifactId>jasync-r2dbc-mysql</artifactId>
<version>1.1.7</version>
</dependency>insert into database report this error:
Caused by: java.lang.UnsupportedOperationException: An operation is not implemented: couldn't find mapping for class java.time.LocalDateTime
at com.github.jasync.sql.db.mysql.binary.BinaryRowEncoder.encoderFor(BinaryRowEncoder.kt:100) ~[jasync-mysql-1.1.7.jar:na]
at com.github.jasync.sql.db.mysql.encoder.PreparedStatementExecuteEncoder.encodeValue(PreparedStatementExecuteEncoder.kt:62) ~[jasync-mysql-1.1.7.jar:na]
at com.github.jasync.sql.db.mysql.encoder.PreparedStatementExecuteEncoder.encodeValues(PreparedStatementExecuteEncoder.kt:46) ~[jasync-mysql-1.1.7.jar:na]
at com.github.jasync.sql.db.mysql.encoder.PreparedStatementExecuteEncoder.encode(PreparedStatementExecuteEncoder.kt:27) ~[jasync-mysql-1.1.7.jar:na]
at com.github.jasync.sql.db.mysql.codec.MySQLOneToOneEncoder.encode(MySQLOneToOneEncoder.kt:67) ~[jasync-mysql-1.1.7.jar:na]
at com.github.jasync.sql.db.mysql.codec.MySQLOneToOneEncoder.encode(MySQLOneToOneEncoder.kt:23) ~[jasync-mysql-1.1.7.jar:na]
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[netty-codec-4.1.58.Final.jar:4.1.58.Final]
... 33 common frames omitted
this is my entity example
import java.time.LocalDateTime;
public class MyEntity {
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
}I saw this part of the code for the BinaryRowEncoder
fun encoderFor(v: Any): BinaryEncoder {
return this.encoders.getOrElse(v::class.java) {
return when (v) {
is CharSequence -> this.stringEncoder
is java.math.BigInteger -> this.stringEncoder
is BigDecimal -> this.stringEncoder
is ReadableDateTime -> DateTimeEncoder
is ReadableInstant -> ReadableInstantEncoder
is LocalDateTime -> LocalDateTimeEncoder
is java.sql.Timestamp -> SQLTimestampEncoder
is java.sql.Date -> SQLDateEncoder
is java.util.Calendar -> CalendarEncoder
is LocalDate -> LocalDateEncoder
is LocalTime -> LocalTimeEncoder
is java.sql.Time -> SQLTimeEncoder
is Duration -> DurationEncoder
is java.util.Date -> JavaDateEncoder
is ByteBuffer -> ByteBufferEncoder
is ByteBuf -> ByteBufEncoder
else -> XXX("couldn't find mapping for ${v::class.java}")
}
}
}can add support for java.time.LocalDateTime ?
Activity
github-actions commentedon Mar 9, 2021
Thank you for reporting an issue. See the wiki for documentation and gitter for questions.
oshai commentedon Mar 9, 2021
Hi, thanks for reporting. Currently the library uses joda time for dates. There was an attempt to replace that in the past but it was never completed, see: #131
The easiest workaround is to use Date/Time object from joda lib.
oshai commentedon Mar 9, 2021
BTW - having support only for writing it to the db is much simpler (the problem is what type to read), so if only that required it might be simpler to implement.
github-actions commentedon May 9, 2021
Stale issue message
dragneelfps commentedon May 27, 2021
can we reopen this? This is a much needed feature.
oshai commentedon May 30, 2021
We can reopen this, mostly if you're willing to implement it.