这是我想要执行的scalaquery查询,
...
def generateFares(scheduleId:NamedColumn[Int], toCityId:NamedColumn[Int], fromCityId:NamedColumn[Int]):List[(String,Int,String)] = {
var list:List[(String,Int,String)] = Nil;
val q = for {
tf <- ticketingDB.ticketFares if (( tf.scheduleId is scheduleId ) && ( tf.fromCityId is fromCityId ) && ( tf.toCityId is toCityId ))
tft <- ticketingDB.ticketFareType if tft.id is tf._7
}{
list = (tft._2, tf._5, tf._6)::list
}
list
}
...在这个连接中,我得到了一个编译错误:
could not find implicit value for parameter session: org.scalaquery.session.Session在第二个调用中。(tft <- ticketingDB)
我无法理解scalaquery的这种行为。
ps:我可以保证该方法是在withSession块中调用的。
请帮助我调试和创建无错误的联接。
发布于 2011-09-20 11:28:31
很抱歉,我将这个解决方案作为评论发布,
我自己想出了答案。您应该导入threadLocalSession以获取会话对象。
import org.scalaquery.session.Database.threadLocalSession https://stackoverflow.com/questions/7468853
复制相似问题