From: Cristian B. <cr...@na...> - 2006-10-19 05:28:42
|
hello http://tequila.best.eu.org/hibernate/lbg/lbg.jsp?lbginfo=Timisoara compare it with http://tequila.best.eu.org/rudi-k/lbg/lbg.jsp?lbginfo=tm they are similar aren't they? :))) observations: - the hibernate row uses makumba 0.6.1 with the usual TESTkaramba. no special database needed. unlike 0.6 and 0.6.0.1, makumba 0.6.1 _prevents_ any kind of Hibernate "schema update", in order not to interfere with makumba index and table management. do not use 0.6 or 0.6.0.1!!! - the above means that, with makumba 0.6.1, plus the needed hibernate JARs, the localhost_mysql_TESTkaramba.cfg.xml, and a dummy SEED.txt file (all of these can be copied from the hibernate context), _anybody_ can use hibernate HQL in their context! but mind the problems below... - expressions like x=y or x<>y don't work as projections (HQL bug, Rudi will communicate with Hibernate people), so i commented out all code with mak:if, although it should be easy to transform it in c:if - lbg.id doesn't work (.id has another semantic in hibernate). you either have to rename the field, or have to find another notation for the hibernate id. due to this, the page parameter changed from lbginfo=tm to lbginfo=Timisoara, and it is impossible to show the id... see the "Code" see also http://www.makumba.org/issues/Makumba-Hibernate-QL_differences.html are there any other fields called "id"? one idea: since HQL class and property names are case sensitive, why not using ID or Id for the hibernate id field? - there are problems in hibernate with expr="label.field1.field2". they pass the hibernate SQL generator, but the generated SQL is wrong (see below) instead, you can use where="... label join label.field1 f1" and then expr="f1.field2" this is a hibernate bug. - it is a bit clumsy to work with HQL at this point because many hibernate queries pass the Makumba HQL analyzer but fail to execute in hibernate (e.g. the ones using lbg.mailingLists instead of in(lbg.mailingLists) ). the trouble is, the real error appears on the log, while on the page we get the useless java.lang.NullPointerException at org.hibernate.hql.antlr.HqlSqlBaseWalker.aliasedSelectExpr(HqlSqlBaseWalker.java:1703) etc etc maybe the mak HQL analyzer should invoke the hibernate analyzer to detect such issues at page analysis (rather than at page execution when hibernate finds them...). it would be even better that the mak analyzer detects the issues (like "use IN( ) or JOIN for sets" in this case) but we surely can't anticipate them all - hibernate resource creation (sessionfactory) takes place at first HQL query execution, and is a bit resource-consuming, seems to take a lot of memory which makes linux slow and needs parade restart sometimes. maybe we can trigger it directly at context reload (via a init() method in some servlet or filter), not sure if that will help... at least the reload won't finish without a factory being ready... maybe a more economical hibernate cache configuration will help, especially since we don't use the hibernate cache anyway... there are other issues to configure for hibernate, e.g. the connection pool. - hibernate "show SQL" is left on, just to see if it generates the right stuff. can be turned off from localhost_mysql_TESTkaramba.cfg.xml --------------------- the 2nd hibernate bug: (the 1st is related to = and <> in SELECT projections). Rudi, should be easy to translate it for Hibernate people. just show the HQL and the wrong SQL, plus maybe the relationships for this: <mak:list from=" join lbg.membershipHistory history" orderBy="history.event.start DESC"> <tr class="${even_Hist? "even" : "odd"}"> <c:set var="even_Hist" value="${!even_Hist}" /> <td><a href="${pageContext.request.contextPath}/events/event.jsp?event=<mak:value expr='history.event.bestNo' />"><mak:value expr="history.event.name" /></a></td> <td><mak:value expr="history.status" /></td> </tr> </mak:list> makumba generates roughly this hibernate query: SELECT lbg.id as col0, history.id as col1, history.status as col2, history.event.start as col3 from best.internal.Lbg lbg join lbg.membershipHistory history order by col3 DESC hibernate generates this SQL query: select lbg0_.Lbg_ as col_0_0_, membership1_.membershipHistory_ as col_1_0_, membership1_.status_ as col_2_0_, event2_.start_ as col_3_0_ from best_internal_Lbg_ lbg0_ inner join best_internal_Lbg__membershipHistory_ membership1_ on lbg0_.Lbg_=membership1_.Lbg_ best_internal_Event_ event2_ where ^ missing comma membership1_.event_=event2_.Event_ and lbg0_.name_=? order by event2_.start_ DESC see the trouble? there's a missing comma in the WHERE clause. i actually discovered this with a simpler test case :) however, this works <mak:list from=" join lbg.membershipHistory history join history.event e" orderBy="e.start DESC"> <tr class="${even_Hist? "even" : "odd"}"> <c:set var="even_Hist" value="${!even_Hist}" /> <td><a href="${pageContext.request.contextPath}/events/event.jsp?event=<mak:value expr='e.bestNo' />"><mak:value expr="e.name" /></a></td> <td><mak:value expr="history.status" /></td> </tr> </mak:list> cristi |