object Database is not a member exception on slick typesafe extensions for oracle.

1.5k views Asked by At

I am trying to port scala/angular tutorial (https://github.com/pcleary00/play-angularjs) over to oracle using typesafe extensions for slick. Really appreciate any help/guidance/x I did the following changes: 1. added library dependencies to build.scala

resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/maven-releases/"     
val appDependencies = Seq(    
jdbc,
"com.typesafe.slick" %% "slick" % "2.0.0-M3",
"com.typesafe.play" %% "play-slick" % "0.5.0.8",
"com.typesafe.slick" %% "slick-extensions" % "2.0.0-M3",    
"org.joda" % "joda-money" % "0.9"
)

Then application.conf

db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.url="jdbc:oracle:thin:host-name:port/sid"
db.default.user=scott
db.default.password="tiger"

Then imports:

import com.typesafe.slick.driver.oracle.OracleDriver.simple._
import scala.slick.driver.ExtendedDriver
import scala.slick.lifted.ColumnOption.PrimaryKey
import Database.threadLocalSession
import scala.slick.session.Database
import play.api.db.DB
import play.api.Play.current

Looks like it was able to find the extensions but I got the following errors:

[info] Compiling 8 Scala sources and 1 Java source to C:\tmp\play-angularjs-master\target\scala-2.10\classes...
[error] C:\tmp\play-angularjs-master\app\Global.scala:4: object Database is not a member of package scala.slick.session
[error] import scala.slick.session.Database
[error]        ^
[error] C:\tmp\play-angularjs-master\app\Global.scala:7: object Database is not a member of package scala.slick.session
[error] import scala.slick.session.Database.threadLocalSession

can somebody please help point to a resource?

2

There are 2 answers

0
kong On

play-slick is still built against the 1.0.1 release of slick, so you would probably need to use that version of slick instead of 2.0.0-M3 if you want to use slick with play. Looks like they have an open issue to upgrade.

1
cvogt On

As kong pointed out use 1.0.1 with play-slick for now. IIRC play-slick should come with this dependency automatically. Also do NOT use threadlocalSession. It is safer to use db.withSession{ implicit session => ... /* your queries here */ } instead. Also You do not need to import the Database object. It should come with the .simple._ import. Here is the info you need to get started: http://slick.typesafe.com/doc/1.0.1/gettingstarted.html#dependencies