Ok, i found the solution (using concat):
Code:
public List<User> getAllOrderCreated(Intranet intranet, String alpha, int start, int max){
if(intranet==null){
return this.getSession().createQuery("from User where intranet is null and lastName like concat(?,'%') order by createdAt desc").setParameter(0, alpha).setMaxResults(max).setFirstResult((start-1)*50).list();
}
else{
return this.getSession().createQuery("from User where intranet=? and lastName like concat(?,'%') order by createdAt desc").setParameter(0, intranet).setParameter(1, alpha).setMaxResults(max).setFirstResult((start-1)*50).list();
}
}