开发者

How to implement DAO in Scala?

I would like to implement DAO in Scala as follows:

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

   // T is a "value object", PK is a pri开发者_如何学Pythonmary 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 ?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜