Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAO Architecture #997

Closed
FelixStumvoll opened this issue Jul 18, 2020 · 5 comments
Closed

DAO Architecture #997

FelixStumvoll opened this issue Jul 18, 2020 · 5 comments

Comments

@FelixStumvoll
Copy link

I am currently trying out this library but i'm a bit curious how an architecture with the rich domain model/DAO would look like.
for example i want create a new entity but before i would like to validate the data. in a standard service->dao->db architecture i would do this in the service layer.
however i'm not quite sure how i would do this with the exposed daos.

@sunqitao
Copy link

class PersonService {
companion object{
fun getTopUser():List{
val userList = ArrayList()
transaction {
val res = Users.selectAll().limit(5)
res.forEach {
userList.add(User(id = it[Users.id],name =it[Users.name],email = it[Users.email] ))
}
}
return userList
}
}
}
object Users:Table("user"){
val id = long("id").autoIncrement()
val name = varchar("name",length = 64)
val email = varchar("email",length = 64)
}
data class User(val id:Long,val name:String,val email:String)

@sunqitao
Copy link

User: entity
PersonService:service
Users : Dao

@FelixStumvoll
Copy link
Author

ok so you are splitting up the DAO and the Entity in two seperate classes

@sunqitao
Copy link

ok so you are splitting up the DAO and the Entity in two seperate classes

yes

@bog-walk
Copy link
Member

For future reference, here are links to some opinions on DAO setup and key issues to track regarding DAO entities:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants