0

I have narrowed down the issue like this:

  1. final String[] concreteQueryStrings = QuerySplitter.concreteQueries( hql, factory ); is invoked inside session.createQuery().
    Hql param passed to it is = FROM com.persistence.hibernate.pojo.CC WHERE ID = :ID

  2. The above function returns an empty string array object. Therefore concreteQueryStrings = [];

  3. Because of this length = concreteQueryStrings.length is 0;

  4. Due to this the following two sad events happen. parameterMetadata = new ParameterMetadata( null, null ); returnMetadata = null;

  5. This is causing query.setParameter("ID", 5); to throw QueryParameterException. This is obviously wrong. What is wrong with my HQL that is causing concreteQueries() to return blanks?

BTW I have hibernate 3.4.

Thanks -Anup

Ace
  • 1,501
  • 4
  • 30
  • 49
  • BTW This is happening for many queries. One other query I had tried out was: Query query = session.createQuery("FROM " + FieldData.class.getName() +" ff WHERE ff.fieldData = :fieldData"); – Ace Mar 11 '14 at 01:53
  • you are using an outdated API, is there anything from preventing you from moving to Hibernate 4.2, using annotations and the much nicer Criteria API? – JamesENL Mar 11 '14 at 02:18
  • @James I do use annotations. I was just going through the hibernate internals because it is not parsing the HQL properly and picking up ':params' values. Due to this setParameter() or setLong() or setting anything is throwing exceptions. And it looks likes I am using 4.3.4.Final I checked the POM dependency. I believe its the most current version. – Ace Mar 11 '14 at 02:28

1 Answers1

0

Looking at your Hql param I'd say that something could be wrong with your select syntax. Let's see:

Is CC really a class name, or is it an alias for a class? (Always try to describe the most of the content you can when naming an clas, that will help you latter in coding).

If CC is NOT the class name, then change the path com.persistence.hibernate.pojo.CC with something that references correctly your class: com.persistence.hibernate.pojo.ContentClass

After stating this then you will need to create an alias for your class. In this case, you can use the alias CC normally, let's see:

com.persistence.hibernate.pojo.ContentClass cc

And last, you MUST define the alias of the class of any object you are selecting in your query, otherwise the result will not be the expected. So, you must change the first param of the WHERE syntax to fulfill this requirement, like this:

WHERE cc.ID = :ID

At the end you will see that your query had some changes in it's syntax, so try to change your actual one by the following:

com.persistence.hibernate.pojo.ContentClass cc WHERE cc.ID = :ID

Hope it can help you, let me know if it's not working yet.

Bonifacio
  • 1,482
  • 10
  • 19