Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toplink query question

Status
Not open for further replies.

tom62

Programmer
Nov 12, 2002
152
DE
I wonder if someone could tell me when to use Query Objects or basic session querying with Toplink. What are the advantages of using Query Objects (if there are any)?

Thanks in advance for your reply,

Tom.


Example code with Query Object:

ExpressionBuilder eb = new ExpressionBuilder(MyClass.class);
Expression exp1 = eb.get("name").equal("Browne");
Expression exp2 = eb.get("city").equal("London");
Expression exp = exp1.and(exp2);

ReadAllQuery q = new ReadAllQuery(MyClass.class);
q.setSelectionCriteria(exp);

Vector result = (Vector)session.executeQuery(q);

Example code with basic session querying:

ExpressionBuilder eb = new ExpressionBuilder(MyClass.class);
Expression exp1 = eb.get("name").equal("Browne");
Expression exp2 = eb.get("city").equal("London");
Expression exp = exp1.and(exp2);
Vector result = (Vector)session.readAllObjects(MyClass.class, exp);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top