Search code examples
javadomain-driven-designmybatiscqrs

Java - Using MyBatis with Doman Driven Design and Event Sourcing Pattern


I am beginner for Java software language. I have been working on C# software language.

I would like to ask a question. I have been working on a project that is about a small core banking solution. I wonder if I can use MyBatis,IBatis with CQRS Pattern and Domain Driven Design instead of using org.springframework.data.repository or not. Is using mybatis a good fit for the CQRS pattern?

I have been researching an example project on the Internet, but I could not find it. I wonder if there is an example for me or not.

Do you have any ideas?


Solution

  • DDD and CQRS don't care about the framework you are using for db persistence.
    In the sense that for DDD (the nearest part to the db persistence) has its way, commonly through the repository pattern, to abstract away the persistence.
    So, theoretically you could just create your interfaces for the repositories and implement them using whatever thing you want.
    What is important to DDD is that your implementation for the persistence respect the guarantees needed for the repositories (like storing an aggregate is an atomic operation), but if you can meet them, any implementation will make your domain work as expected.

    About being a good fit, it depends on the benifits your situation can gain from using one or the other, spring data + hibernate are very easy to setup and use, and they also have a lot of automatism already implemented, with IBatis maybe you can write custom queries more performant, as most of the things in computer science, it depends.