design - Models as Scala case classes interacting with DAO? -


i starting design involving scala case classes models, , wondering design decision.

let's imagine have 2 models, user model , order model. order model references user model foreign key.

case class user(id: userid, [other fields...], password: string) case class order(id: orderid, [other fields...], userid: userid) 

then, given design, have orders dao method findbyuser method.

my question is: design have orders method in user calls dao method, , making system more oo, or better keep layers isolated , not include method?

thanks!

if understand correctly, you're asking active record pattern. pattern, has pros , cons, can find more online. here of them:

http://www.mehdi-khalili.com/orm-anti-patterns-part-1-active-record

https://softwareengineering.stackexchange.com/questions/70291/what-are-the-drawbacks-to-the-activerecord-pattern

active record design pattern?

in play2 project, firstly used pattern, because of ebean support. however, since needed bit more logic persisting models, extension of turned cumbersome. in end, separated everything: separate service, separate model, separate dao. helped me switch between repository layer implementations (in end experiment spring data jpa, hibernate etc. more freely)


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -