8

I have a problem with the Scala tutorial for creating an Entity with the play framework (Version 2.1). I'm trying to do:

import java.util._
import javax.persistence._
import play.db.jpa._

But when I compile it tells me that javax.persistence dosen't exist and play.db neither.

I suppose it's a problem of version because it seems to me that the actual yabe-tutorial is a bit old. Do you know any website who has good explanations and examples?

Thanks for your help!

3 Answers 3

3

As you use Scala you could take a look at Slick which seems to be the future db persistence framework for Play and abandon the one in your tutorial.

Look in your Build.scala if you have jdbc as a dependancy.

Here's my dependancies

val appDependencies = Seq(
    jdbc,
    "mysql" % "mysql-connector-java" % "5.1.22",
    "com.typesafe" % "slick_2.10.0-RC1" % "0.11.2",
    "org.mindrot" % "jbcrypt" % "0.3m"
  )
2
  • Thank you very much! I really like Slick.
    – nate-k
    Feb 7, 2013 at 9:12
  • 1
    For anyone reading this, as of Play 2.2.0, they are not planning to move away from JPA. Indeed, the Play 2.3 roadmap says they will move Ebean (Java) and Anorm (Scala) to plugins and support JPA (Java) and Slick (Scala) built in by default Sep 22, 2013 at 8:55
2

build.scala now deprecated. In play 2.2.x add to build.sbt:

libraryDependencies ++= Seq( javaJdbc, javaEbean)
0

I ran in the same issue and I solved it by changing my file Build.scala with

val appDependencies = Seq(
  // Add your project dependencies here,
  javaCore,
  javaJdbc,
  javaEbean,
  "mysql" % "mysql-connector-java" % "5.1.19"
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.