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 ?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With