Font Size: a A A

Implementing ORM With Java's Dynamic Proxy Mechanism

Posted on:2006-02-04Degree:MasterType:Thesis
Country:ChinaCandidate:K HuangFull Text:PDF
GTID:2178360182970159Subject:Software engineering
Abstract/Summary:PDF Full Text Request
ORM--Object-Relation Mapping is a new data-persistence concept that combines Object-Oriented technology with database technology. Through translating and executing mappping rules, it transparently persists objects' persistable information to relation database, and guarantees consistency on the transaction border. It's mainly concerned in data-assemble/dissemble by certain rules, and automatic object initialization and fill-back by reachability.The primary task of ORM is transformation of data represented by object model to relation tables. It has two problems to be solved: First, how to represent object's internal data in form of relational tables; Secondly, how to represent relations between objects. In this article we explained a complete object model mapping method step by step.As the implementation of static ORM relies on recompilation of byte-code, it has problems on issues such as byte-code compatibility and extensibility. This article gives an implementation that uses CGLIB dynamic code generation and Java run-time reflection mechanism, both bases on the widely used Java language.Applying dynamic proxy mechanism to ORM is a tentative application. By proxy object replacement, it injects persistence ability to objects. Meanwhile, it performs data mapping of object model at runtime through data type abstraction and management of proxied objects' data. Thus eliminates static ORM's intrinsic faults.We focus on specific implementation. Our work mainly consists of: 1) Make classes persistable by dynamic proxy. 2)Use reflection to match mapping rules, then persist objects by reachability, and switch proxies' status at the same time. 3) Implement a component capable of mapping object model automatically based on mechanism explained above.The later tests proved this implementation of better performance at data operation's simplicity, mapping efficiency and resource consuming.The synchronization and data lock in distribute enviroment, and long transaction and concurrency in multi-thread enviroment are not our concerns in this article.
Keywords/Search Tags:Persistence, Dynamic-Proxy, Java, Data-Mapping, Code-Generation
PDF Full Text Request
Related items