Hibernate from 2 to 3 solutions that do not support Oracle8 outer joins (+)

Source: Internet
Author: User
Tags joins new features table name

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.