3

考虑这个休眠字段:

@Column(name="datecreated", nullable = false)
@org.hibernate.annotations.Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
private DateTime dateCreated;

我想像这样运行 hql 查询:

String query = "select ticketEvent " +
                   "from TicketEvent ticketEvent " +
                   "where ticketEvent.status = :status " +
                   "and ticketEvent.dateCreated > :highestTicketCommentDate " +
                   "and ticketEvent.ticket.id = :ticketId " +
                   "order by ticketEvent.id DESC";

ticketEvents = (List<TicketEvent>) entityManager.createQuery(query)
                    .setParameter("ticketId", ticket.getId())
                    .setParameter("status", TicketEvent.Status.SAVED)
                    .setParameter("highestTicketCommentDate", highestTicketCommentDate)
                    .getResultList();

这里的highestTicketCommentDate 也是一个joda DateTime。但我得到了错误的结果。比较 hql joda datetime 的正确方法是什么?任何帮助,将不胜感激。

提前致谢

4

0 回答 0