Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

trouble using BINARY in where clause with Hibernate 3.1  RSS feed

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 ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!