![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Hibernate
莫迟疑
程序员
展开
-
Hibernate中in查询条件
public List<User> listByNames(List<String> names) { String hql = "from User where name in (:names)"; Query query = this.sessionFactory.getCurrentSession().createQuery(hql); query.setParameterList("names", names); return query.list;}原创 2021-04-10 11:19:55 · 1532 阅读 · 0 评论 -
Hibernate对int类型进行模糊搜索报错java.lang.String cannot be cast to java.lang.Integer
Fish表的code是int类型,使用Hibernate直接对code进行模糊查询会报错java.lang.String cannot be cast to java.lang.Integer。解决方法:将Hql的String hql = "FROM Fish WHERE deleted = 0 AND code LIKE '%12%' ";改为:String hql = "FROM ...原创 2019-12-21 17:45:32 · 540 阅读 · 0 评论 -
通过修改SpringBoot配置在控制台打印Hibernate/Jpa Sql方法
原文链接:http://codingdict.com/blog/article/2019/5/13/999.html方法修改SpringBoot配置文件,加上如下两句话:logging.level.org.hibernate.SQL=DEBUGlogging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE第一行打印...原创 2019-08-12 14:06:04 · 4184 阅读 · 2 评论 -
maven搭建Hibernate开发环境
通过maven引入依赖,搭建Hibernate开发环境。引入依赖,hibernate-core,junit,mysql-connector-java,log4j,示例如下:<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artif...原创 2019-08-22 08:35:43 · 936 阅读 · 0 评论 -
Hibernate执行原生sql
package com.mark.hibernate.tester;import com.mark.hibernate.utils.HibernateUtils;import org.hibernate.Session;import org.hibernate.query.NativeQuery;import java.util.Iterator;import java.util.L...原创 2019-08-22 12:26:10 · 521 阅读 · 0 评论