atom feed5 messages in org.eclipse.dali-devRe: [dali-dev] JPQL query generation?
FromSent OnAttachments
Tom MutdoschFeb 20, 2007 12:55 pm 
Shaun SmithFeb 20, 2007 1:18 pm 
Tom MutdoschFeb 20, 2007 3:10 pm 
Shaun SmithFeb 21, 2007 6:21 am 
Tom MutdoschFeb 21, 2007 8:48 am 
Subject:Re: [dali-dev] JPQL query generation?
From:Shaun Smith (shau@oracle.com)
Date:Feb 20, 2007 1:18:18 pm
List:org.eclipse.dali-dev

Hi Tom,

There isn't a visual query builder in Dali but JPQL support is on the feature backlog.

I really wouldn't recommend SQL queries. They're there as a last resort. You lose a number of advantages of JPA including encapsulation of the data model. You'll be coupling your code (queries) to the data model. Coupling should be limited to your mappings. Mappings can adapt to data model changes (and Dali will detect them), and your queries can continue to work without change since you're querying on the object model. Also, JPA persistence providers parse JPQL and can do things like avoid database round trips by using a cache. A primary key query is an obvious one. If what you want is in the cache and you know it's reliable why go to the database? When using SQL your provider will just pass it along and process the results so you lower the value of the cache. The big issue IMHO is the unnecessary coupling of queries to the data model and the brittleness it introduces. I've seen database migrations from DB/2 to Oracle of two applications in a workflow, one using TopLink, one using direct SQL. The SQL based application was way more expensive to port. They had to go over every line of SQL whereas the TopLink based application required the mappings adjusted (minimally I might add) and the application ran. Theory is nice but seeing it play out in real life made the advantage of object based queries concrete.

Shaun Tom Mutdosch wrote: Hi all, Is there any way to assist in generating queries (using Java Persistence Query Language) in Dali? For example, is there any visual query builder that can generate a JPQL query? I know the Data Tools Platform provides a visual SQL Builder. It might be nice if there was something similar that Dali could use. For example, someone who doesn't know much SQL but wants to "retrieve all Departments containing Employees with at least 5 years of experience". I know that JPA can also be used with SQL Queries, so maybe that would be the recommended advice for such a user - to use the SQL Query Builder and then supply that query to the EntityManager. How hard would it be for Dali to reuse the SQL Builder to have it generate JPQL instead?

Thanks Tom