Announcement Announcement Module
Collapse
No announcement yet.
getHibernateTemplate() - How to return a sinlgle class ... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • getHibernateTemplate() - How to return a sinlgle class ...

    Hi,

    I want to use getHibernateTemplate().xxx to return a single class.

    Normally I would use something like this:
    ... getHibernateTemplate().get(Class.Item, id);

    But now I have a table with 3 primary-keys.

    What is the best solution to proceed?

    Is this approach any good?

    Code:
    String query = "from de.Item i where i.b = ? and i.bl = ? and i.bla = ?";
    Object obj[] = new Object[3];
    obj[0] = b;
    obj[1] = bl;
    obj[2] = bla;
    return (Sflight) this.getHibernateTemplate().find(query, obj).get(0);
    Thanks
    Jonny

  • #2
    Code:
    I want to use getHibernateTemplate().xxx to return a single class
    Try: DataAccessUtils.uniqueResult(Collection results) or DataAccessUtils.requiredUniqueResult(Collection results)

    Comment

    Working...
    X