Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

trouble using BINARY in where clause with Hibernate 3.1

Bridget Kennedy
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am attempting to migrate from Hibernate 2.1 to 3.1. I installed Hibernate 3.1.0_beta4. MySQL is the underlying DB implementation. Hibernate 3.1 is having trouble with a couple of named queries that do work with the older 2.1 version. The trouble occurs when using BINARY as a where clause qualifier. I prefix BINARY in a search to impose case sensitive string search ( re. mysql manual: string comparison ).

My named query looks something like this in the .hbm.xml file:

This worked just as I wished in 2.1, but with 3.1, I get the following runtime exception while attempting Configuration.rebuildSessionFactory():

org.hibernate.HibernateException: Errors in named queries:

There is no specific information provided to direct me to the cause of the error. However, the exception is not thrown if I remove the BINARY qualifier from the where statement.

Has anyone else seen or heard of this?

I found the following in a Hibernate 3 Migration notes doc:
Query Language Changes
Hibernate3 comes with a brand-new, ANTLR-based HQL/SQL query translator. However, the Hibernate 2.1 query parser is still available. The query parser may be selected by setting the Hibernate property hibernate.query.factory_class. The possible values are org.hibernate.hql.ast.ASTQueryTranslatorFactory, for the new query parser, and org.hibernate.hql.classic.ClassicQueryTranslatorFactory, for the old parser. We are working hard to make the new query parser support all queries allowed by Hibernate 2.1. However, we expect that many existing applications will need to use the Hibernate 2.1 parser during the migration phase.

[ March 02, 2006: Message edited by: Bridget Kennedy ]
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!