Announcement Announcement Module
Collapse
No announcement yet.
HibernateTemplate.find(queryString, value,type) removed in Hibernate3? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HibernateTemplate.find(queryString, value,type) removed in Hibernate3?

    Hello,

    I am in the process of upgrading to Hibernate3 and changing all our dao classes to use org.springframework.orm.hibernate3. I have found that all the Hibertemplate.find signatures that had 3 parameters :
    List find(final String queryString, final Object[] values, final Type[] types),
    List find(String queryString, Object value, Type type) etc. were removed.

    At first this seemed like a small migration issue which required simply running a search and replace to remove the type parameter from all the method calls. As I began testing, I found a bigger issue. When using the find method with 3 parameters, if any of the parameters passed to a dao method were unexpectedly a null value, the dao method would return an empty list. Now that hibernate has to determine the type, a null passed into a method has dire consequences and exceptions such as these are thrown:
    Dec 16, 2005 3:52:19 PM org.hibernate.util.JDBCExceptionReporter logExceptions
    WARNING: SQL Error: 932, SQLState: 42000
    Dec 16, 2005 3:52:19 PM org.hibernate.util.JDBCExceptionReporter logExceptions
    SEVERE: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY

    I know that one obvious and simple solution will be to go through all the dao code and ensure that it is checking for nulls. However, I'm wondering why these signatures were removed from this version and if there is any plan to add them back?

    Thank you very much.
    Ursula

  • #2
    You can check the forum for more explanations but officially the methods have been removed because there the API become too large and these methods were just for convenience. There were just some specific cases were they could be used - you can simply use HibernateCallback to do the same thing (and you don't have to use any array or anything like that actually).

    Comment

    Working...
    X