Beginner |
|
Joined: Fri Mar 12, 2004 1:02 pm Posts: 23
|
Hi,
I'm trying to create new DAOs using hibernate stateless sessions due to integration requirements and for particular retrieve methods I consistently run into the hibernate exception: "org.springframework.orm.hibernate3.HibernateSystemException: collections cannot be fetched by a stateless session".
I've been following the stateless session example from the hibernate docs--http://www.hibernate.org/hib_docs/v3/reference/en/html/batch.html--using Scrollable results with no success. Here is a snippet of the retrieval method in my DAO:
------------
StatelessSession session = getSessionFactory().openStatelessSession();
Transaction tx = session.beginTransaction();
try {
Customer customer = null;
Query query = session.createQuery("FROM Customer WHERE customerCode = :customerCode");
query.setString("customerCode", customerCode);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
if (results.next()) {
customer = results.get(0);
}
return customer;
} catch (HibernateException he) {
throw convertHibernateAccessException(he);
} finally {
tx.commit();
session.close();
}
---------------
Any help would be appreciated. Thanks!
-los
|
|