I am having trouble converting MySQL Query into appropriate Hibernate code. Specifically the following SQL
select a.id, b.id as id, b.timestamp as timestamp, b.speed as speed from abc a join xyz b on b.abc_id = a.id left xyz b2 on (a.id = b2.abc_id and b.timestamp < b2.timestamp OR b.timestamp = b2.timestamp AND b.id < b2.id))
Above query is run perfectly and got expected result but when I tried to convert into Hibernate Criteria then I have no idea about bellow code
(a.id = b2.abc_id and (b.timestamp < b2.timestamp OR b.timestamp = b2.timestamp AND b.id < b2.id))
I have already tried following code
Criteria criteria = currentSession().createCriteria(Abc.class);
criteria.createAlias("xyz", "b");
criteria.createAlias("xyz", "b2");
criteria.add(Restrictions.le("b.timestamp", "b2.timestamp"));
criteria.add(Restrictions.lt("b.id", "b2.id"));
But it does not work as per MySql Query