hello,everyone.I'm programming with Hibernate Framework for two month.Today I come up to a strange question.When I used session.createQuery(
hql) to get data ,it works well.However , When I used session.createQuery(
sql) to get data , an ClassCastException occured.How does it happen?What should I do?
The code:(The last line throws the excetption)
Code:
hql = "SELECT a.* FROM business.tb_gl_userInf a WHERE (a.registerType =4 "+ "AND a.registerTime BETWEEN '" + yesterday + "' AND '"+ today + "') OR (" + "a.mulRegTime BETWEEN '" + yesterday+ "' AND '" + today + "')";
log.info(hql);
List<TbGlUserInf> lsa = session.createSQLQuery(hql).list();
log.info(lsa.size());
Iterator<TbGlUserInf> itu = lsa.iterator();
while (itu.hasNext()) {
TbGlUserInf tu = itu.next();
The following is OK:
Code:
hql = "FROM TbGlUserInf a WHERE (a.registerType =4 "+ "AND a.registerTime BETWEEN '" + yesterday + "' AND '"+ today + "') OR (" + "a.mulRegTime BETWEEN '" + yesterday+ "' AND '" + today + "')";
log.info(hql);
List<TbGlUserInf> lsa = session.createQuery(hql).list();
log.info(lsa.size());
Iterator<TbGlUserInf> itu = lsa.iterator();
while (itu.hasNext()) {
TbGlUserInf tu = itu.next();