The equivalent of left
requires substring()
with three arguments. The second is the offset and the third is the number of characters. So, to get the first four characters:
Query query = HibernateUtil.getSessionFactory().getCurrentSession().createQuery("from User where substring(user, 1, 4) like :user");
The expression substring(user, 4)
usually takes the substring starting at the fourth character to the end of the string (I say "usually" because that is typical behavior of the function but I don't know if HQL exactly does that).