Skip to main content

Posts

Showing posts from July, 2010

Hades: DRY principle in JPA/Spring development

It's almost two weeks after great Javarsovia 2010 conference, but before I write few words about this event, let me mention about really clever library called Hades. I owe you this after my attendance in GeeCON 2010, where I discovered this tool during its author talk.

DRY stands for Don't Repeat Yourself and if you were developing in JPA for a while you have violated this principal several times. Take for example this piece of code:




Although IntelliJ IDEA has a wonderful support for JPA (have you noticed this little popup suggesting me the proper named query parameter name since?), I still have to write the same boilerplate code over and over. Basically for each entity object I need a DAO class and 90% of them look the same except they have different entity type. Same CRUD, same paging and sorting logic, same unit tests, similar queries. We are getting bored after writing fifth or tenth DAO like this, especially if we are lazy (which is good!) So Hades provides nice abstractio…