Results 1 to 2 of 2

Thread: getHibernateTemplate() - How to return a sinlgle class ...

  1. #1
    Join Date
    Apr 2005
    Posts
    9

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

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

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. Replies: 3
    Last Post: Sep 4th, 2005, 11:11 PM
  5. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM

Posting Permissions

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