This is an old post but I was trying to achieve the same with Criteria API and couldn't find the "right" way.
This was the only post that helped when googling for a solution, hope this can help to someone else too.
Currently this works for me using Criteria API:
Using what James post suggests with Criteria API:
will not work.
Note: I'm using PostgreSQL so that's why I use RANDOM function instad of RAND.