2011-09-19 10 views
7

đây là một truy vấn scalaquery mà tôi muốn thực hiện,scalaquery vấn đề không có phiên ngầm

... 
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 
    } 
... 

Trong tham gia này, tôi nhận được một lỗi biên dịch:

could not find implicit value for parameter session: org.scalaquery.session.Session 

trong cuộc gọi thứ hai. (tft < - ticketingDB)

tôi không thể hiểu được hành vi này của scalaquery.

ps: tôi có thể đảm bảo phương thức được gọi bên trong khối withSession.

hãy giúp tôi gỡ lỗi và tạo lỗi tham gia miễn phí.

+0

xin lỗi vì đã làm phiền các bạn, nhưng tôi đã tự tìm ra giải pháp. tôi đã không nhập threadLocalSession vào tập tin. nhập org.scalaquery.session.Database.threadLocalSession – tiran

+0

nếu bạn tự mình tìm ra câu trả lời, hãy đăng câu trả lời. – geowa4

Trả lời

14

Xin lỗi, tôi đăng giải pháp làm nhận xét,

Tôi đã tự tìm câu trả lời. bạn nên nhập threadLocalSession để lấy đối tượng phiên.

import org.scalaquery.session.Database.threadLocalSession 
+3

Đối với slick: 'import scala.slick.session.Database.threadLocalSession' – lreeder

+0

Slick 2.0 yêu cầu nhập khác: http://slick.typesafe.com/doc/2.0.0/migration.html#dynamically-and-statically- scoped-sessions – rhodri