Hi,
It seems I have found an error in Hibernate documentation.
Pls review...
First and foremost I am newbie in the Hibernate word (3 months old) so I could be wrong (but my code works)
I wanted to restrict the results returned by my Hibernate class.
So wrote a static method, employing "Criteria Queries"
As per documentation
http://www.hibernate.org/hib_docs/reference/pdf/hibernate_reference.pdf, "
8.3.6 Criteria Queries" shud be used as :
Quote:
List cats = session.createSQLQuery("SELECT {cat.*} FROM CAT AS {cat} WHERE ROWNUM<10","cat",Cat.class).list();
But I found that the
AS clause in the 'FROM <tablename> {<alias>}' part gives an exception (SQL Not properly ended)
It works fine without the
AS clause
Of course I am working with an Oracle 9i database. (WinXP os, with WSAD)
my WORKING code:
Code:
public static List fetchOfflinePartnersWithProducts() throws PersistenceException {
List partnerList = null;
try {
Session session = HibernateSession.currentSession();
partnerList = session.createSQLQuery(
"SELECT {p.*} FROM PARTNER {p} WHERE p.partner_id IN " //further code removed for clarity
"p", Partner.class).list();
} catch (HibernateException e) {
throw new PersistenceException(e);
} catch (PersistenceException e) {
throw new PersistenceException(e);
}
return partnerList;
}
Any comments ?