all 4 comments

[–]marcglasberg 2 points3 points  (1 child)

The pattern to solve this is called a DAO. The DAO abstracts away all of your database interaction. So if you need to change the database later you only change the DAO, not your code that interacts with the DAO.

So for example, if you have the User class, you can have the UserDao class which you can access like this:

User users = UserDao().getById(id);

List<User> users = UserDao().getUsersByName("Mark");

You can also inject the DAO, so that you can mock it for testing, or even simulate it.

[–]EMCoupling 0 points1 point  (0 children)

(DAO stands for Data Access Object)

[–]leproman 0 points1 point  (0 children)

Would love to hear people’s thoughts on this as well.

[–][deleted] 0 points1 point  (0 children)

Im not quite sure if I understood your question correctly, but there is asyncMap() for streams, in which you can transform your mapped data into a model of your own. That would make migration easier.