我正在尝试将 Doobie 与 oracle 一起使用,但遇到了一些类型问题:
我有一张桌子:
create table TEST
(
CREATED_ON TIMESTAMP(6) not null,
A VARCHAR2(50) not null,
B VARCHAR2(50) not null,
C VARCHAR2(50) not null,
)
我有一个案例课
import java.sql.Timestamp
case class Test(created_on: Timestamp, a:String, b:String, c:String)
当我尝试编译 Doobie 抱怨 Timestamp 类型时,如果我将类型更改为 String 它会编译但插入失败。根据文档,应支持时间戳:https ://tpolecat.github.io/doobie/docs/12-Custom-Mappings.html
它可能是 Oracle 特有的吗?
Error:(36, 13) Cannot find or construct a Read instance for type:
com.juliusbaer.quant.analytics.persistency.Test
This can happen for a few reasons, but the most common case is that a data
member somewhere within this type doesn't have a Get instance in scope. Here are
some debugging hints:
- For Option types, ensure that a Read instance is in scope for the non-Option
version.
- For types you expect to map to a single column ensure that a Get instance is
in scope.
- For case classes, HLists, and shapeless records ensure that each element
has a Read instance in scope.
- Lather, rinse, repeat, recursively until you find the problematic bit.
You can check that an instance exists for Read in the REPL or in your code:
scala> Read[Foo]
and similarly with Get:
scala> Get[Foo]
And find the missing instance and construct it as needed. Refer to Chapter 12
of the book of doobie for more information.
.query[Test]