Hibernate HQL to basic SQL (no joins)
I working on a project with Hibernate and we need to replace Hibernate with some "home made persistence" stuff. The idea is that the project is big enough, and we have many HQL qu开发者_StackOverfloweries. The problem is with the queries like
select a,b from table1, table2 on t1.table1=t2.table2
Basically all joins are not supported by our "hand made persistence" stuff.
What I would need, is to be able to do some sort of transcoder, which will take as a input the HQL queries and output some SQL, but SQL without joins
I hope you get the idea. My persistence layer does not supports joins.
Does anybody has any idea about something like that? Some framework, or something?
You can't do what that example HQL is doing without a JOIN of some sort. What you can do is implement the joins in a View and then use your home grown stuff to query the view. That insulates you from the implementation of the joins. The only way to get what you want without a JOIN somewhere is query each table and then merge the results in your code.
It appears you don't want to get rid of the joins but to express them in the very old SQL89 form. Either way it is still a join.
SQL92 Syntax:
SELECT FROM TABLE1 T1
JOIN TABLE2 ON T1.ID = T2.ID;
SQL89 Syntax:
SELECT FROM TABLE1 T1, TABLE2 T2
WHERE T1.ID = T2.ID;
I am surprised anything that would cost money these days would fail to support an almost two decades old syntax.
精彩评论