Hi,
I want to seperate the Ebean stuff out of my models to be able to test my Business rules inside my models. I know I can test with fakeApplication but I rather not want to.
In PHP I have used repository pattern, but with Ebean I just do now know how to implement the find method in a generic way.
My proposal:
All business models will implement the BaseModelInterface. This is just an empty interface.
The I want to have the following user repository interface which can have their additional queries defined
- Interface BaseRepositoryInterface
- findById(Long id)
- save()
- update()
- delete()
- findAllPaged(int pageNumber)
- etc...
- Interface UserRepositoryInterface
- findUserByEmail(String email)
- findUserByUserName()
Abstract class BaseRepository implements BaseRepositoryInterface
Then I would have a UserRepository that extends the BaseRepository but implements the UserRepositoryInterface so that inside UserRepository I would have to implement the specific User queries.
Does anyone had to do something specific? In the documentation the repository is referenced but no implementation details with Ebean:
Link to docs
Please advise me how to achieve this?
Regards,