Database Answers Logo
Toplink Discussion 2

Montreux, Switzerland
I use Toplink for Java. Toplink basically generates dynamic SQL for your 
normal "queries" and may also turn that into a stored procedure on the 
RDBMS side. The normal SQL mappings are one thing. Need to discuss? A 
second thing is a Query object framework where you build up your query 
using objects and the framework will generate the dynamic SQL. Here is an 

public Vector getTests(Study study) {
   ExpressionBuilder builder = new ExpressionBuilder();
   Expression studyId = builder.get("study").get("oid").equal(study.getOid
   ReadAllQuery query = new ReadAllQuery();
   return new (Vector) getSession().executeQuery(query));

which gets all "Test" objects for a particular "Study" by performing a join 
between the study and tests. IOW, return all Tests where == 

You can think of this simply as some objects that can generate OO queries 
into SQL strings and pass them along to the RDBMS, although Toplink handles 
caching, converting to/from objects and so forth. Toplink could also 
compile a query or sql string into a stored procedure if I wanted, e.g., I 
would give this query a name, tell Toplink to convert it to a stored 
procedure, then refer to it by name.

Since it's inefficient to dynamically generate the sql string and have the 
RDBMS recompile it every time, Toplink could tell the RDBMS to convert this 
sql string to a stored procedure then use this stored procedure reference 
via parametrized calls thereafter (for the lifetime of the Toplink object; 
it would delete these temporary stored procedures when it shut down).

Toplink also has an execute(aSQLString) method where you can just send a 
SQL string directly to the database. This is a "backdoor" that bypasses the 
unitOfWork (transaction in object terms) and caching. In general, this will 
answer a Vector of "DatabaseRows" or ResultSets. Up to you what you want to 
do with it.

I apologize if I failed to answer your question. I wasn't quite sure what 
you wanted so I scattershot-ed it. If your question was: "Does Toplink 
really SP its queries then use parametrized calls to them going forward?", 
to be honest I'd have to go back and look at Toplink's code to see. It 
doesn't seem very difficult to do, so I assumed it would. But I'm not 100% 
sure. Hmmm.

Incidentally, I was just informed about a new open source OR Java tool 
today at I was planning on looking at it 

[ Home Page | Ask me a Question | Email | FAQs | History of Databases | Useful Links ]

© IceBreaker WebDesigns 2000