Results 1 to 2 of 2

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

  1. #1
    Join Date
    Dec 2005
    Posts
    1

    Default 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. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •