Alex Rivera | Logout

How to implement DAO in Scala?

Asked 2011-03-19T16:23:06.610
15

I would like to implement DAO in Scala as follows:

trait DAO[PK,-T,-Q] {

   // T is a "value object", PK is a primary key, and Q is query parameters.

   def create(t:T):Unit
   def update(t:T):Unit
   def remove(pk:PK):Unit
   def find(query:Q):Seq[T]
}

Does it make sense ? Doesn't it look "too Java" ? How would you design/implement DAO in Scala ?

Edit
Report

1 Answer

4

I think Scala allows more direct and straightforward work with SQL databases than Java'ish DAO.

You may want to check out http://squeryl.org/ and other frameworks mentioned in this great answer: https://stackoverflow.com/questions/1362748/wanted-good-examples-of-scala-database-persistence/2318935#2318935

answered 2011-04-14T23:11:27.720

Your Answer