JPA OrderBy不工作

时间:2014-10-24 15:13:58

标签: sql jpa-2.0 derby glassfish-4 java-ee-7

这是一个相当简单的jpa查询,但排序永远不会有效。如果我添加ASC或DESC无关紧要

SELECT hfp FROM Lap l INNER JOIN l.footprints hfp WHERE l.id = :id ORDER BY hfp.date ASC

在此查询之后,我的输出始终相同。

Query query = em.createNamedQuery("findHardwareFootprintsWithLapIdOrderByDateASC");
        query.setParameter("id", lapId);
        List<HardwareFootprint> results = query.getResultList();
        System.out.println(results);

输出:

[Footprint[ id=21 type=NormalHandshake date=05/10/2014 08:13:41.808], Footprint[ id=20 type=NormalHandshake date=05/10/2014 08:13:21.123], Footprint[ id=18 type=NormalHandshake date=05/10/2014 08:13:11.512]]

SQL日志:

SELECT t0.ID, t0.DATE, t0.TYPE FROM HARDWAREFOOTPRINT t0, LAP_HARDWAREFOOTPRINT t2, LAP t1 WHERE ((t1.ID = ?) AND ((t2.Lap_ID = t1.ID) AND (t0.ID = t2.footprints_ID))) ORDER BY t0.DATE ASC

有人有想法吗?

0 个答案:

没有答案