Search code examples
activerecordspring-roospring-data

Spring Roo with ActiveRecord vs Spring Data


I'm starting a new Spring project and have decided to try out Spring Roo. In setting up the persistence layer, I see that Spring Roo supports (actually even defaults to) the ActiveRecord pattern. While I have always been a DAO/DTO fan in the past, Roo makes a very good case for using the ActiveRecord pattern, as it seems to "hide" most of the ActiveRecord methods in the apsect files.

Does anybody know why the Spring Roo developers would default ROO to use the AR pattern when Spring Data does such a beautiful job of providing/hiding CRUD (the typical bain of DAO patterns)? Is Spring trying to push more people to use the AR pattern instead of the Repo pattern?


Solution

  • I believe this was because the ActiveRecord paradigm from the Rails/Ruby camp showed alternatives to the full stack we are used to. Here is how the Spring team puts it:

    We have removed the DAO layer because it is not strictly essential to creating the typical web applications that most people are trying to build

    It's also worth observing that most modern RAD frameworks avoid DAO layers and add persistence methods directly to entities. If you compare similar technologies to Roo, you will see this avoidance of a DAO layer is commonplace, mainstream and does not cause problems.

    Source: http://static.springsource.org/spring-roo/reference/html/architecture.html#architecture-dao

    That said, I've used Roo with the class application tiers with success. The advantage is that it feels more "Spring"y, and since we can remove Roo and inline all the IDTs, long term maintenance may be simpler.

    More recently, I'm using the ActiveRecord way because the Roo shell still doesn't support dynamic finders when using repositories. I'm not hopeful that they will get around to it anytime soon: https://jira.springsource.org/browse/ROO-2694