I am working on a Java application (an ERP) that has grown pretty large, and will continue to grow for the next couple of years. We have been using Spring-JDBC for our DAO layer. But the amount of boilerplate code that needs to be written is slowing us down significantly, not to mention introducing silly bugs in the system.
So now we’re looking for a solution that will:
-
Reduce the amount of time we need to spend on the DAO layer
-
Doesn’t have a very steep learning curve
-
Gives us control over our queries, like we have with JDBC.
-
We should be able port our existing code part-by-part, not all at once.
I thought MyBatis would be a good choice, but I’m not sure if it would satisfy all our requirements. In particular, would it be able to work alongside our Spring-JDBC code without creating problems in transaction management, handling concurrency etc?
Edit: Forgot to mention that we’re using Spring-AOP for transaction management, which we’d prefer to continue with.
Thanks!
Our apps use Spring and iBatis everything. (well 99% of everything else, we still have some jdbc code that hasn’t been ported yet). We are also using Spring AOP for txn managment.
In short, MyBatis+Spring AOP will work for you. It also works well with DBUnit for DAO integration testing.
MyBatis is good solution of given problems.
You can still use spring-aop with MyBatis as like in spring-jdbc.
It will take so very less, to migrate your queries from Spring-JDBC to MyBatis. MyBatis is very easy to learn and provides Object mappers to automatic convert native SQL query data to pojos. If you are using spring-jdbc, you already have java beans, those you can reuse with MyBatis.