When I using this code to get the data from DB. It will get stackoverflow problem.
Code:
result.addAll(getCurrentSession().createCriteria(User.class)
.add(Restrictions.ilike("name", "tom", MatchMode.ANYWHERE))
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
.list());
User is a class have a one to many relationship to 3 other class.
If I update the the code to this. It will not get the problem.
Code:
StringBuilder hql = new StringBuilder();
hql.append("SELECT distinct user FROM ")
.append(" User as user")
.append("WHERE lower(user.name) = :name ");
getCurrentSession().createQuery(hql.toString())
setString("name", "%"+s+"%").list();
Is anyone know what the problem is?