Does hibernate query result always return a list?

Posted by Phoenix on Stack Overflow See other posts from Stack Overflow or by Phoenix
Published on 2012-09-14T15:36:13Z Indexed on 2012/09/14 15:37 UTC
Read the original article Hit count: 524

Filed under:

Does a query execution always have to return a list ? How do I replace the code below if I am sure it will only return a single object ?

@Override
    public List<DocInfo> findAllByDocId(String docId)
    {
        Query q = getCurrentSession().createQuery("from DocInfo item where item.id = :docId");
        q.setString("docId", docId);
        List<DocInfo> docInfoList = q.list();
        return docInfoList;
    }

© Stack Overflow or respective owner

Related posts about hibernate