This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigBEAEE6D33E96361040A606E3
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable
Hi,
I'm currently developing a small app, based on EJB 3.0. I created a
named query like this:
--- cut --- cut --- cut --- cut ---
@[EMAIL PROTECTED]
(name =3D "topItems", query =3D "select i from Orderitem oi in=
ner
join oi.item i group by i order by sum(oi.quantity) desc")
--- cut --- cut --- cut --- cut ---=09
--- cut --- cut --- cut --- cut ---
public Collection<Item> getTopItems()
{
Query q =3D em.createNamedQuery("topItems");
q.setMaxResults(25);
return (Collection<Item>) q.getResultList();
}
--- cut --- cut --- cut --- cut ---
But this doesn't seem to work like I expect it to work: I get an
exception from the JDBC-driver :( It seems like my database (MySQL)
doesn't like the "sum(oi.quantity)" in the order by clause :(
well, I played with the sql, and it seems like MySQL would prefer
something like this:
--- cut --- cut --- cut --- cut ---
@[EMAIL PROTECTED]
(name =3D "topItems", query =3D "select i, sum(oi.quantity) as=
qty from Orderitem oi inner join oi.item i group by i order by qty desc")=
=09
--- cut --- cut --- cut --- cut ---
But this in turn doesn't seem to work with hibernate, at least I tried
to evaluate this expression in the HQL-Editor, and hibernate could not
create a SQL-statment :(
-=3D-=3D-
=2E.. Black holes suck.
--------------enigBEAEE6D33E96361040A606E3
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
iQCVAwUBRfVb7tXV+99RZLuBAQJUsQQAmIgMvcmVlEIu3QBrqjXnzgKCxyJjio8r
qCTGawwQyyzT8XaWONxzB0MdHMHpffn8IFNKmX61E/HFeN/KqYqN+OdLycAAgQTl
A3LMPCGsnfC/tyZN7WV7X1GT9wJ+XziIz0RugYbF+Q0MPqMcXWb60nBGmk3QU3BS
LUUy67IXIwo=
=n+uP
-----END PGP SIGNATURE-----
--------------enigBEAEE6D33E96361040A606E3--


|