Announcement Announcement Module
Collapse
No announcement yet.
How to access Query parameters from Hibernate Template ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to access Query parameters from Hibernate Template ?

    Hi,


    I would like to use setMaxResults and setFirstResult on Hibernate Query object.

    How can I get access to Query object from HibernateTemplate ?

    Thanks,
    eozzeo

  • #2
    The HibernateTemplate is a helper class for reduce the coding (ex load, update, ex.) but if you whant use particular Hibernate function you should use HibernateCallback that exposed a session refer...
    Example:

    boolean test = ((Boolean) template.execute(new HibernateCallback() {

    public Object doInHibernate(Session session)
    throws HibernateException, SQLException {

    try {
    // generic code use Session

    } catch (Exception e) {
    e.printStackTrace();
    return Boolean.FALSE;
    }
    return Boolean.TRUE;

    }

    })).booleanValue();

    Comment

    Working...
    X