Extracting Queries by Static Analysis of Transparent Persistence

Ben Weidermann and William Cook of UT Austin have put together a paper on translating procedural code into SQL.

From the abstract:

"Transparent persistence promises to integrate programming languages
and databases by allowing procedural programs to access
persistent data with the same ease as non-persistent data. When the
data is stored in a relational database, however, transparent persistence
does not naturally leverage the performance benefits of relational
query optimization.We present a program analysis that combines
the benefits of both approaches by extracting database queries
from programs with transparent access to persistent data."

You can find the paper here.