English 中文(简体)
如何在Schala实施DAO?
原标题:How to implement DAO in Scala?
  • 时间:2011-03-19 16:23:06
  •  标签:
  • scala
  • dao

我愿以下列方式在Schala实施保护儿童组织:

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 ?

问题回答

我认为,Schala比Java ish DAO数据库更直接、更直截了当的工作。

页: 1 https://stackoverflow.com/questions/1362748/wanted-good-examples-of-scala-database-persistence/2318935#2318935“https://stackoverflow.com/questions/1362748/wanted-good-examples-of-scala-database-persistence/2318935#2318935





相关问题
Spring Annotations not working

I posted this to the spring forums, sorry for the xpost. I am new to spring. I am working on an existing project that uses spring 1.2.8 (old, I know), and java 1.5 so annotations should work. I am ...

Using JSF, JPA and DAO. Without Spring?

till now i still worked with JSF and JPA without DAOs. Now i d like to use DAOs. But how can i initialize the EntityManager in the DAO-Classes? public class AdresseHome { @PersistenceContext ...

JPA @Version: how to use it?

@Entity public class Person { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; private int salary; @Version private long version; // ...getters and ...

DAO/Repository/NHibernate And Handling Edge DB Cases

One thing that keeps stumping me, and I do not see much mention of it in books/blogs, is how to handle DB operations in a system that really don t fall under the jurisdiction of DAOs or Repositories. ...

DAO, ORM and Queries

There is a need to update one field to the same value in a heap of records. Using the DAO/ORM structure, I would retrieve each parent object, loop through each child object, update it s field, and ...

DAO Best practices : Querying Parent / Children

Given you have a domain model with a simple parent / child relationship, and each entity has it s own associated DAO, eg: Author AuthorDAO Book BookDAO If I want to add a DAO method for retrieving ...

Can I do this Generic thing?

It seems I m missing something with Java Generics because something I think is simple, it appears to me that can´t be done. Maybe you can help... This is the scenario: I m coding a generic abstract ...

Pros and cons of the use of the DAO pattern [closed]

As I mention in the title, I m interested to know what you (as experienced developers) think about the use of the DAO pattern, specifically within a web application. What advantages have you found and ...

热门标签