-->
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.  [ 2 posts ] 
Author Message
 Post subject: mysql an createSqlQuery
PostPosted: Sun Jan 07, 2007 6:55 am 
Newbie

Joined: Sun Jan 07, 2007 6:35 am
Posts: 1
Environment:
MySql 5.0.22-community-nt
Hibernate 3.1.3


Hello,

this native SQL-Query:

select s.internetsuche_id, e.inetsuchergebnis_id,
s.bezeichnung, s.datum, e.datum,
count(es.inetsuchergseite_id), s.queryparameter
from internetsuche s
left outer join inetsuchergebnis e
on s.internetsuche_id = e.internetsuche_id
left outer join inetsuchergseite es
on e.inetsuchergebnis_id = es.inetsuchergebnis_id
group by e.inetsuchergebnis_id
order by s.internetsuche_id, s.datum, e.datum;

results in e.datum set to s.datum in every row.

Code: (Breakpoint at createSQLQuery)

private List internQuery(String pQueryString, boolean pNativeMode) {
List retList = null;
Query query = null;
StringBuffer queryString = new StringBuffer();
try {
session = sessionFactory.openSession();
Transaction t = session.beginTransaction();
queryString.append(pQueryString);
if (pNativeMode == true) {
query = session.createSQLQuery(queryString.toString());
} else {
query = session.createQuery(queryString.toString());
}
retList = query.list();
t.commit();
return retList;
} catch (RuntimeException e) {
sessionFactory.getCurrentSession().getTransaction().rollback();
throw e;
} finally {
session.close();
}
}


Executing the query on the mysql console gives the correct results:
if there is a NULL in the first left outer join condition
(no corresponding row in internetsuchergebnis e)
e.datum is set to null and
if there is a corresponding row e.datum is set correctly.


Greetings
Gerhard


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 07, 2007 7:20 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
What is the problem? I can't find the question (and please use the tags to make your code more readable).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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

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.