The java.util.Map DAO

The more I code, the fewer dependencies I am willing to create.

For example, I used to have a common super interface that all persistent objects must inherit from in order to have an id-field. I used to have a common DAO interface that all DAOs implemented. But these add hard dependencies in my code.

Hiding the super interface for all entities was easy. Doing away with the DAO is harder. But I can use Maps to get rid of almost all custom code. There are two exceptions so far: Querying and some DAO utility operations like flushing.

The following is a proof-of-concept test. The code necessary to make it pass is not yet available, but I am envisioning the Map being replaced by a lazy but smart HibernateObjectMap without changing the code. Any feedback on this code would be welcome.

About Johannes Brodwall

Johannes is Principal Software Engineer in SopraSteria. In his spare time he likes to coach teams and developers on better coding, collaboration, planning and product understanding.
This entry was posted in Java, Software Development. Bookmark the permalink.