对象/关系映射持久化框架实现了对象属性与关系数据库表项之间的自动映射,极大简化了面向对象系统中的数据持久存储问题.但是,现有的对象/关系映射框架要求显式调用持久化接口,这就需要在业务逻辑代码中插入大量持久化代码,不仅带来程序结构的不清晰,更重要的是,使应用的持久化功能缺乏动态适应性.基于现有主流持久化技术,本文提出一种对象/关系映射隐式持久化框架,该框架支持隐式持久化,即,应用系统不需出现任何与持久化相关代码,由框架将封装后的持久化代码注入到应用系统中,使系统能按需配置持久化策略以实现对象持久化.隐式持久化技术不仅可以使应用开发者更专注于业务逻辑,而不需要关心持久化,且允许动态修改持久化策略,从而实现持久化箫略的增删改.
Object/Relational Mapping (ORM) frameworks cat'automatically maintain the mapping between object attributes and relational database tables, greatly simplifying the data storage problems when developing an object-oriented system. However, existing ORM frameworks need the application codes explicitly call the persistence interface, which means that them will be many persistence codes scattered over and tangled with the business code. It not only makes the program structure unclear, more importantly, but also leads to the lack of dynamic adaptability for ever-changing persistence requirements. Based on existing popular persistence frameworks,this paper presents an implicit persistence framework of ORM, called Persistence on Demand (POD). First of all, POD makes persistence implicit, i. e., there is no code related to persistence in the application while an object can become persistent by defining a persistence strategy. Based on the implicit persistence,POD makes the persistence runtime adaptable by dynamically re-configuring the persistence strategy.