8

I am new to Play and Scala, and I am reading Play for Scala from Manning press. I would like to use the instructions to use Squeryl instead of Anorm.

The book mentions that I need to initialize Squeryl in a class that extends GlobalSettings.

import org.squeryl.adapters.H2Adapter
import org.squeryl.{Session, SessionFactory}
import play.api.db.DB import play.api.{Application, GlobalSettings}

object Global extends GlobalSettings {
    SessionFactory.concreteFactory = Some(() =>
    Session.create(DB.getConnection()(app), new H2Adapter) ) 
...

As this is an early edition (MEAP) it is not clear about where to place this code... So I after a little digging on the play site I found the following example that extends GlobalSettings

import play.api._

object Global extends GlobalSettings {

    override def onStart(app: Application) {
        Logger.info("Application has started")
    }  

    override def onStop(app: Application) {
        Logger.info("Application shutdown...")
    }  

}

The play example gives a little more help but I am still unable to follow the directions, which state : This object must be defined in the default (empty) package.

Which leads to my question: Where does one place a scala file in the Play Framework 2.0 so that it is complied as part of the default package?

Thanks for any help...

paradigmatic
  • 40,153
  • 18
  • 88
  • 147
Frobbit
  • 1,652
  • 17
  • 30
  • 1
    I conflated two issues in my own code. It must be a class/object called Global.scala. It can reside anywhere under the app folder. – Frobbit Jul 04 '12 at 01:39
  • 1
    We're changing all the code listings so that it's clear where all the files go. Also there is a copy-paste error in that example in the book; the 'def onStart' line is missing (should be the first line in the Global object). This is also on the todo list. Hopefully we'll get that in by the next MEAP update. – Francisco Canedo Jul 08 '12 at 05:59

2 Answers2

8

GlobalSettings object typically resides in app/Global.scala. Look at zentasks sample.

lambdas
  • 3,990
  • 2
  • 29
  • 54
0

This does not answer your specific asked question

But, if your question is about "how to use squeryl with Play2 ?", there are some resources you can have a look at :

Community
  • 1
  • 1
kheraud
  • 5,048
  • 7
  • 46
  • 75