My web application has got a lot of service tables/entities, such as payment_methods
, tax_codes
, province_codes
, etc.
Each time I add a new entity, I have to write a DAO. The thing is that, basically, they are all the same, but the only difference is the entity class itself.
I know that Hibernate tools can generate the code for me automatically but I can't use them now (don't ask why) so I'm thinking of a Generic DAO. There's a lot of literature about that but I can't put pieces together and make it work with Spring.
It's all about generics I think, it will have four basic methods:
listAll
saveOrUpdate
deleteById
getById
and that's all.
Question:
What's the best practice for not re-inventing the wheel? Isn't there something ready to use, yet?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…