Safe query objects

William R. Cook, Siddhartha Rai

2005 · 120 citations · 16 references

Concepts

TL;DR

Developers of data‑intensive applications increasingly use persistence frameworks such as EJB, Hibernate, and JDO, which support transparent persistence and explicit queries, but explicit queries lack static type and syntax checking because they are string‑based and interpreted at runtime. The paper introduces Safe Query Objects, a technique that represents queries as statically typed objects yet allows remote execution by a database server. Safe query objects translate query classes into database queries using object‑relational mapping and reflective metaprogramming, supporting complex joins, parameters, existentials, and dynamic criteria. A prototype JDO implementation demonstrates a type‑safe interface to the full query functionality of the JDO 1.0 standard.

Abstract

Developers of data-intensive applications are increasingly using persistence frameworks such as EJB, Hibernate and JDO to access relational data. These frameworks support both transparent persistence for individual objects and explicit queries to efficiently search large collections of objects. While transparent persistence is statically typed, explicit queries do not support static checking of types or syntax because queries are manipulated as strings and interpreted at runtime. This paper presents Safe Query Objects, a technique for representing queries as statically typed objects while still supporting remote execution by a database server. Safe query objects use object-relational mapping and reflective metaprogramming to translate query classes into traditional database queries. The model supports complex queries with joins, parameters, existentials, and dynamic criteria. A prototype implementation for JDO provides a type-safe interface to the full query functionality in the JDO 1.0 standard.

References

16