Hibernate
LittleSunlight
希望能够好好的学习技术
展开
-
第一次配置hibernate时,Junit测试时不报错的可能原因
前几天看了一下教程 ,自己试着配置了一下web下的hibernate,悲剧的时,出错了提示下面: org.hibernate.HibernateException: Unable to get the default Bean Validation factory at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyD...转载 2019-03-14 12:09:45 · 272 阅读 · 0 评论 -
hibernate+mysql查询时用中文失败的解决方法
今天在写大作业的时候,再用hibernate按中文查询mysql时,他总是失败, HQL语句是String hql=“from User as u where u.name=”+“小明”; 在网上查了许多方法,什么数据库的字符集不是utf-8;还有在hibernate连接数据库的配置中,在地址后面添加东西,如下: jdbc:mysql://localhost/s2sh?useUnicode=tru...原创 2019-05-31 10:39:45 · 297 阅读 · 0 评论 -
org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions错误
org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions 这是我今天用session.save()保存数据时遇到的错误 这是一个可能会很常见的错误 他的意思是“打开两个非法对话资源”,原因是之前打开的session没有关闭,在其中又打开了一个session,导...原创 2019-06-01 14:42:35 · 894 阅读 · 0 评论 -
hibernte关联关系时删除数据库的数据
例如 User{ … List scart=new ArrayList() … } Scart{ … } 在这之中user与list有关联关系,并且通过user来删除list中的对象。 我们用List scarts=user.getScart();来获取到scarts集合。然后用 scarts.remove()方法来删除,remove我们可以通过两种方式来删除一是 通过对象scarts.remov...原创 2019-06-03 13:20:22 · 278 阅读 · 0 评论