-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Different results from HQL Editor and from the java code
PostPosted: Mon Jun 04, 2007 8:43 am 
Newbie

Joined: Mon Jun 04, 2007 4:32 am
Posts: 2
Firstly I will explain my problem:

Following HQL works in the HQL-Editor:

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)


The same HQL does not work within the Java Code. In the below code fragment

List result = session.createQuery(search).list();

the list is empty where search is the HQL.

Does anybody know the answer?




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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.