Hibernate的sql查询

今天用Hibernate来执行sql语句,简单总结一下

 

SQLQuery query = null;
query = session.createSQLQuery("select * from fun as ca,(select * from comment as r1 where r1.created_at>=all(select r2.created_at from comment as r2 where r1.fun_id=r2.fun_id)) as re where ca.id=re.fun_id order by re.created_at desc;");
List<Fun> list = query.addEntity(Fun.class).list();

 如果没有最后一行的addEntity方法,在执行过程中会产生

org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
 类似异常!

你可能感兴趣的:(sql,Hibernate,jdbc)