Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [dali-dev] JPQL query generation?

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
_______________________________________________
dali-dev mailing list
dali-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dali-dev

--
Shaun Smith
Principal Product Manager
Oracle TopLink
shaun.smith@xxxxxxxxxx



Back to the top