简体   繁体   English

在隐式val GetResult中分散隐式扩展

[英]diverging implicit expansion in implicit val GetResult

Using slick and following the examples, I have created a implicit val to convert my result like this: 使用光滑并按照示例,我创建了一个隐式val来转换我的结果,如下所示:

implicit val getLocationResult = GetResult(r => LkpLocation(r.<<, r.<<, r.<<, r.<<))
val marketsQuery1 = sql"exec get_locations @ProjectId = ${projectID.get}, @ObjectId = $objectID, @ComponentTypeID = 1".as[LkpLocation]

However I get a strange error message: 但是我收到一条奇怪的错误消息:

diverging implicit expansion for type scala.slick.jdbc.GetResult[T] starting with method createGetTuple22 in object GetResult

What is the cause of this error? 这个错误的原因是什么? Is there perhaps another way I can declare the implicit conversion that would be more stable? 是否有其他方法可以声明更稳定的隐式转换?

Ensure the class you're converting to contains only types slick's PositionedResult can handle using it's << method. 确保您要转换的类只包含类型光滑的PositionedResult可以使用它的<<方法处理。 For a list of all types see the other methods of PositionedResult. 有关所有类型的列表,请参阅PositionedResult的其他方法。

I got this error when using a java.util.Date on my target class while PositionedResult's method nextDate returns a java.sql.Date. 我在目标类上使用java.util.Date时遇到此错误,而PositionedResult的方法nextDate返回java.sql.Date。 Declaring the target class's date field as java.sql.Date then solved the problem. 将目标类的日期字段声明为java.sql.Date然后解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM