Ich habe folgendes Problem:
Die Liste "result" bleibt leer, wenn ich folgende HQL-Abfrage aus dem Java-Programm heraus aufrufe.
select
count(*)
from
Consumerview
where
id.lastName in (
select
lastName
from
Psconsumer
where
status = 'loaded' and status in ('generated', 'loaded', 'locked', 'used', 'broken', 'saved') and isCompany= false)
Wenn ich aber die selbe Abfrage aus dem HQL-Editor aufrufe, dann erhalte ich ein Ergebnis.
Kann mir da jemand helfen?
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.0
Mapping documents:
Code between sessionFactory.openSession() and session.close():
public static List executeSearch(String search) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List result = session.createQuery(search).list();
System.out.println("SEARCH: " + search);
// Workaround for Sessions Problem (lazy Initialization)
if ((!search.equals("from Status")) && (!search.equals("from Stati"))
&& (!search.contains("from Gisaddresses where status"))
&& (!search.contains("from Sim"))
&& (!search.contains("from Msisdn"))
&& (!search.contains("from Fln"))
&& (!search.contains("count(*) from Psconsumer"))
&& (!search.contains("from Bankaccountview"))
&& (!search.contains("Consumerview"))
&& (!search.contains("count(cons) from Psconsumer"))) {
System.out.println("Bin wieder drin!");
for (Iterator it = result.iterator(); it.hasNext();) {
Psconsumer psc = (Psconsumer) it.next();
Hibernate.initialize(psc);
Hibernate.initialize(psc.getAccounts());
Hibernate.initialize(psc.getBankAccounts());
Hibernate.initialize(psc.getGObjects());
Hibernate.initialize(psc.getPssubscriptions());
}
}
/*
* if((search.contains("from Addresses where status")) ){ for(Iterator
* it=result.iterator();it.hasNext();){ Addresses
* psc=(Addresses)it.next(); Hibernate.initialize(psc); } }
*/
session.getTransaction().commit();
// session.close();
return result;
Full stack trace of any exception that occurs:
Name and version of the database you are using: Oracle 9
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html