Recently took over a project to maintain, is written in Hibernate2+oralce8, because see Hibernate3 page out so long, but also feel Hibernate3 has many of its new features, such as bulk deletion and update, the new HQL parser ast.
The upgrade process roughly follows the Sun Weichen article how to upgrade Hibernate2.1 to Hibernate3.0? To do, replace the replacement, the settings, the program runs, when the program execution to the following query (Oracle unique external connection query), error.
The statement is: (described as a similar statement, the actual table name in the project is hidden)
Session.createquery ("Select T1.c1,t2.c1 from Table1 t1,table2 T2 where T1.C1=T2.C1 (+)"). List ();
The error message is:
org.hibernate.hql.ast.QuerySyntaxException:unexpected token:) Near line 1, column A [select T1.c1,t2.c1 from Tab Le1 t1,table2 T2 where T1.C1=T2.C1 (+)]
at Org.hibernate.hql.ast.QuerySyntaxException.convert ( querysyntaxexception.java:31)
at Org.hibernate.hql.ast.QuerySyntaxException.convert ( querysyntaxexception.java:24)
at Org.hibernate.hql.ast.ErrorCounter.throwQueryException (errorcounter.java:59
at Org.hibernate.hql.ast.QueryTranslatorImpl.parse (querytranslatorimpl.java:258)
at Org.hibernate.hql.ast.QueryTranslatorImpl.doCompile (querytranslatorimpl.java:157)
at Org.hibernate.hql.ast.QueryTranslatorImpl.compile (querytranslatorimpl.java:111)
at Org.hibernate.engine.query.hqlqueryplan.<init> (hqlqueryplan.java:77)
at Org.hibernate.engine.query.hqlqueryplan.<init> (hqlqueryplan.java:56)
at Org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan (queryplancache.java:72)
at Org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan (Abstractsessionimpl.java:133)
at Org.hibernate.impl.AbstractSessionImpl.createQuery (abstractsessionimpl.java:112)
at Org.hibernate.impl.SessionImpl.createQuery (sessionimpl.java:1623)
And look back at the Sun Weichen. The change in the 1.3 query statement mentions that Hibernate3.0 adopts the new ANTLR hql/sql query translator Astquerytranslator, It already does not support the Theta-style connection query dialect like Oracle8i and Sybase11.
There are two ways to solve this problem:
(1) Instead use a dialect that supports Ansi-style connection queries, like left OUTER join ... On.. The wording
(2) You can also use the Hibernate2 query translator, which can be configured in Hibernate.cfg.xml.