Monday, November 12, 2012

Spring Roo - ActiveRecord and Repository/DAO/Service pattern

If you are used to Dao/Services pattern, you need to have patience to get used to ActiveRecord (in other words, bye bye Dao) pattern Spring Roo uses.

Spring Roo does support Repository (other word for Dao if this is between you and me) , and service pattern. But at least, in Spring Roo 1.2.2 , it has limited support. Primarily, support for finder methods and creating web pages based on finder methods.

if you are using ActiveRecord pattern, your finders get exposed to web (when you do web mvc finder all) to web GUI. But at least in my trials with Repository/Service, I did not get that reward from Roo.

Repository/Service implementation is based on Spring Data, which is umbrella project for all types of database accesses. Its amazing powerful, ( one should read its finder methods signature based automation), but if you want to stick to Spring Roo's automation for UI. You will need to wait or write web pages by hand.

If you want to stick to ActiveRecord pattern, you will need to get used to writing business logic in controllers and entity methods. Not bad if you get that automation !

After playing with it, I expect that "web mvc json all" command will give me Json interface which I can call from my Javascript client. ! I have already realized its not going to follow typical REST pattern because Spring Roo creates finders with URL parameters "find=ByUserAnd..".

My tweets on similar topics