Announcement Announcement Module
Collapse
No announcement yet.
Hibernate like query Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate like query

    Hello everybody,

    I am trying too build a search query.
    Example:
    Code:
    List<IKit> loadAll = getHibernateTemplate().find("from KitImpl k where k.type like '%?%' ",kitType);
    But i get the following error:
    java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!

    But when i use the following query:
    Code:
    List<IKit> loadAll = getHibernateTemplate().find("from KitImpl k where k.type like '%a%'");
    It works fine.

    So it is a problem with the ? ?

    Can anybody tell how i can solve the problem.

  • #2
    Rewrite your query remove the '% and %'.. Don't use quotes in your query.

    Code:
    List<IKit> loadAll = getHibernateTemplate().find("from KitImpl k where k.type like   ? ", "%" + kitType + "%");

    Comment


    • #3
      Thanks a lot....

      Comment

      Working...
      X