Adding to the previous comment: The generated query looks like this and thus fails to run on PostgreSQL:
select token0_.id as col_0_0_ from token token0_ where token0_.valid_until<? order by token0_.id asc for update of