Hibernate version: 2.1.6
Mapping documents: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping package="com.dti.changetracking"> <class name="Location" table="CHANGE_LOCATION"> <id name="id" type="integer"> <generator class="native"/> </id> <property name="description" type="string" not-null="false"/> <property name="active" type="int" not-null="false"/> </class> </hibernate-mapping>
Code between sessionFactory.openSession() and session.close(): try{ Transaction tx= hs.beginTransaction(); try{ Query query = hs.createQuery("from Location l where l.description = :d"); query.setString("d", "Moscow"); for (Iterator it = query.iterate(); it.hasNext();) { Location l = (Location) it.next(); out.println("Location description: " + l.getDescription() + "<br>"); } tx.commit(); } catch(Exception e){ tx.commit(); HibernateFactory.closeSession(); throw e; }
Full stack trace of any exception that occurs:
Name and version of the database you are using: MS SQL 2000
Debug level Hibernate log excerpt:
I can see following in stdout.log
Hibernate: select location0_.ID as x0_0_ from CHANGE_LOCATION location0_
Hibernate: select location0_.ID as ID0_, location0_.description as descript2_0_, location0_.active as active0_ from CHANGE_LOCATION location0_ where location0_.ID=?
First of all i don't understand why there is a couple queries?
Both of them looks OK.
But as reasult i got expetion message - cannot load (class_name)#(instance number)
I able to load single object using session. But cannot do that with multiple objects. Whats wrong?
|