is there any difference between Criteria and HQL for query an object?
Hibernate version:3.0
Mapping documents:
Code:
<class deviceInfo>
...
<many-to-one name="deviceType" column="device_type" class="DeviceType" fetch="join" not-null="true"/>
...
Code between sessionFactory.openSession() and session.close():Criteria:
Code:
resultList = session.createCriteria((DeviceInfo.class))
.list();
HQL:
Code:
Query query = session.createQuery("from DeviceInfo");
resultList = query.list();
Doubt is:
after close the session, I can get infomation of DeviceType(class, may to one in DeviceInfo) when I use Creteria, but I can't get the information of DeviceType when I use HQL.
How can I get the same result, thanks....