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
|