
Hibernate
潘敬
这个作者很懒,什么都没留下…
展开
-
Hibernate缓存
缓存是介于物理数据源与应用程序之间,是对数据库中的数据复制一份临时放在内存中的容器,其作用是为了减少应用程序对物理数据源访问的次数,从而提高了应用的运行性能。Hibernate在进行读取数据的时候,根据缓存机制在相应的缓存中查询,如果在缓存中找到了需要的数据(我们把这称做“缓存命中"),则就直接把命中的数据作为结果加以利用,避免了大量发送SQL语句到数据库查询的性能损耗。 Hibernat转载 2013-04-25 23:40:32 · 1015 阅读 · 0 评论 -
Spring + iBatis 的多库横向切分简易解决思路
原文地址:http://www.iteye.com/topic/781317转载 2014-04-04 17:09:14 · 1022 阅读 · 0 评论 -
Hibernate插入数据成功,不报错,但是数据库中没有值
原因是没有提交事务加入属性true这样就可以自动提交事务了。原创 2014-03-24 17:16:58 · 10486 阅读 · 1 评论 -
根据Hibernate实体对象,自动生成数据字典
效果图:代码:package com.jxc.util;import java.io.File;import java.io.FileWriter;import java.lang.reflect.Field;import java.lang.reflect.Method;import java.text.SimpleDateFormat;import java.util.A原创 2014-01-15 15:39:53 · 2453 阅读 · 0 评论 -
hibernate注解方式实现一对多映射
首先是在hibernate.cfg.xml中引入要映射的class "-//Hibernate/Hibernate Configuration DTD 3.0//EN""http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> com.mysql.jdbc.Driver转载 2014-01-11 11:57:56 · 812 阅读 · 0 评论 -
Hibernate插入数据效率测试
硬件配置:4G内存、CPUi3-2.3数据库SQL2008package com.pan.test;import org.hibernate.Session;import org.hibernate.Transaction;import com.pan.bean.Student;import com.pan.uitl.HibernateSessionFactory;原创 2013-07-30 23:33:50 · 2072 阅读 · 0 评论 -
使用hibernate在5秒内插入11万条数据,你觉得可能吗?
需求是这样的,需要查询某几个表的数据,然后插入到另外一个表。一看到需求,很多人都会用hibernate去把这些数据都查询出来,然后放到list中,然后再用for循环之类的进行遍历,一条一条的取出数据对对象进行赋值,然后在调用dao层的save 方法进行保存对象。hibernate保存一条数据是在35毫秒左右,咱们来计算下时间:35*110000=3850000 毫秒385000原创 2013-08-02 22:32:02 · 4035 阅读 · 0 评论 -
Struts2+hibernate 实现分类无限级 并找出所有分类 ( 二 )
这是第二种方法:返回需要的结果集public String indexInit(){ //获取所有的父级 List bases=categoryService.findByBaseId(0); List> datas=new ArrayList>(); for (Category category : bases) { List list=new ArrayL原创 2013-05-14 22:36:58 · 1393 阅读 · 0 评论 -
Struts2+hibernate 实现分类无限级 并找出所有分类
迷迷糊糊的搞出来了。。感慨万千啊。。。public String indexInit(){ //获取所有的父级 recursion(0); System.out.println(dList.size()); for (Category category : dList) {原创 2013-05-14 22:14:53 · 1366 阅读 · 0 评论 -
Struts2 多条件组合查询和准备默认数据
在使用SSH的时候,会在DaoImpl中生成 findByExample 和findByAll一般情况在 我们都会在execute方法中使用findByAll 去给页面准备数据加入你jsp页面中 包含了这个Action 那么就会出现数据 覆盖的问题那么现在 在execute方法中 直接使用 findByExample查询方法 也在execute中 不必在去写代码原创 2013-05-10 11:40:45 · 2339 阅读 · 0 评论 -
三大框架整合 提示 不能进行查询错误
这是抛出来的提示信息:HTTP Status 500 - could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute querytype Exception reportmessage could not execute原创 2013-05-16 22:16:22 · 1559 阅读 · 0 评论 -
org.hibernate.LazyInitializationException: could not initialize proxy - the owning
问题表现为:org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed 出现的原因:当两个表有外键相连时,对一个表加载之后session随之关闭,导致相连的表无法加载 解决方法:在关联的hbm文件中,对于set里的lazy一定要设成“f原创 2013-05-02 13:31:46 · 1228 阅读 · 0 评论 -
hibernate update和delete方法无效
getSession().flush();加上这句就可以了,直接提交到数据库,不对缓存进行操作。不然就是对缓存进行操作。原创 2014-03-26 12:55:19 · 3594 阅读 · 1 评论