我在使用 Hibernate 时遇到问题,在执行我的一个查询后,我收到以下日志消息并且程序停止工作:
20:36:48,805 TRACE ThreadLocalSessionContext:344 - allowing proxied method [createQuery] to proceed to real session
4608 [main] TRACE org.hibernate.context.ThreadLocalSessionContext - allowing proxied method [createQuery] to proceed to real session
20:36:48,806 TRACE QueryPlanCache:128 - located HQL query plan in cache (from Propertylist where typedlistId = ?)
4609 [main] TRACE org.hibernate.engine.query.QueryPlanCache - located HQL query plan in cache (from Propertylist where typedlistId = ?)
在实践中,我有一个小方法,我称之为:
public List<Zielobjekt> gibZielobjekte() {
List<Zielobjekt> zielobjekte = new ArrayList<Zielobjekt>();
Session session = _sessionFactory.getCurrentSession();
session.beginTransaction();
for(Informationsverbund iv : gibInformationsverbuende() /*Behind this method is a Hibernate query, it works fine.*/ )
{
Set<Celement> zobjekte = gibBaumelementeFuerVater(session, iv.getOriginalId());
LOGGER.info("Insgesamt " + zobjekte.size() + " ZO gefunden.");
for(Celement element : zobjekte)
{
Set<Propertylist> eigenschaften = gibEigenschaftsliste(session, element); /*Behind this Method is a Hibernate Query, here the Program stops to work.*/
//HERE THE PROGRAM STOPS WORKING
...
}
}
session.getTransaction().commit();
return zielobjekte;
}
程序停止工作的调用方法是:
private Set<Propertylist> gibEigenschaftsliste(Session session, Celement element)
{
try
{
return new HashSet(session.createQuery(
"from Propertylist where typedlistId = ?")
.setInteger(0, element.getEntityId())
.list());
}
catch (HibernateException e)
{
e.printStackTrace();
return null;
}
}