ORM and RDBMS, how to make them working together

11:4016/11/2019

ORM helps developers to speed up the coding, security, maintenance and it is independently from RDBMS engine; some of ORMs have also several caching level capabilities (i.e. Hibernate ehcache) that increase overall performances. Furthermore ORM do not require the knowledge of query language (SQL), so the developers do not need additional skills to write the code. This is fine when you use pure ORM and the application structure is not “complicated”, in this way you loose some of very useful RDBMS functionality such views/triggers/store and so on; in same cases is very helpful to delegate to RDBMS some specific actions that can be performed better by the RDBMS engine. The problem is: how to keep ORM cached data aligned with RDBMS data when something happens at RDBMS level (i.e. a DELETE CASCADE is triggered)?
In our complex projects we built a structure to work around the problem, in this way we have the possibility to use the ORM capabilities and the power of RDBMS together getting the best from both of them.