Reputation: 48460
I am attempting to write a helper class for querying my database. It looks something like this:
object Injury {
def logger = LoggerFactory.getLogger(getClass)
def find(teamId: Int = 0) {
logger.info("teamId in find(): " + teamId)
teamId match {
case 0 => findAll
case n => findById(n)
}
}
def findAll = {
val results = InjuryDAO.findAll
results.map(grater[Injury].asObject(_)).toList
}
def findById(teamId: Int) = {
//
}
}
Now in my controller, I can simply call Injury.find(someId)
and field the correct results. The problem is I'm not seeing any results, so I believe my Scala logic is incorrect somewhere. If I call Injury.findAll
directly from my controller, all works great. in this case I'm passing a 0, verified it with the logger, but the case 0
which should invoke findAll isn't being triggered properly. Obvious error here?
Upvotes: 0
Views: 63
Reputation: 22181
def find(teamId: Int = 0) {
=
is missing, explaining why your method doesn't return anything (Unit
).
Should be:
def find(teamId: Int = 0) = {
Upvotes: 1