zw7534313的博客 -凯发k8国际

`
文章列表
hibernate search  使用过lucene的人都知道,lucene是使用directory这个概念来存储索引文件的,所以在hibernate search中提供了一个初始化、配置化的工厂类directoryprovider来生成相应的directory.   感觉compass的优势在于通用性好,基本上所有的orm和jdbc都支持,hibernate search只支持hibernate和jpa.
 1.设置里 lazy = "false" 会导致 org.hibernate.lazyinitializationexception: could not initialize proxy - the owning session was closed "org.hibernate.lazyinitializationexception: could not initialize proxy"延迟抓取出的错,hb3对many-to-one的默认处理是lazy = "proxy",把所有many-to-one,one-to-one都加 ...
hibernate数据检索策略:     hibernate的数据检索策略是面向对象的策略,对于不同的数据检索情况,应使用不同的策     略,以提高效率和节省资源。经常使用的是立即检索和延迟检索,预先抓取是同一级别     的策略,因为它们是三选一的策略。用了其中一个则另外两个就都不可用,而且被延迟   加载的对象当最终被加载时,一定是使用立即加载的形式
基本值类型: java基本类型、对应的hibernate映射类型和标准的sql类型 hibernate映射类型 java类型 标准
hibernate事务隔离级别: 隔离级别 脏读 (dirty read) 不可重复读 (nonrepeatable read) 幻读 (phantom read)
hibernate数据检索策略:hibernate的数据检索策略是面向对象的策略,对于不同的数据检索情况,应使用不同的策略,以提高效率和节省资源。经常使用的是立即检索和延迟检索,预先抓取是同一级别的策略,因为它们是三选一的策略。用了其中一个则另外两个就都不可用,而且被延迟加载的对象当最终被加载时,一定是使用立即加载的形式(指select 语句的形式). 批量检索可以优化立即和延迟加载,它们可以同时用。 (1) 立即检索:立即检索的配置文件标识符为lazy=”false”.对象的属性域、一对一关联对象、多对一关联对象,由于这些被关联的对象是”一”这端,适合立即检索。而一对多和多对一关联对象则不 ...
生成model类的serialversionuid: 在命令提示符下:执行serialver  类路径   类名   例如:c:\program files\java\jdk1.6\bin>serialver  -classpath e:\workspace\app\bin\    util.test     在序列化时,有几点要注意的:  1:当一个对象被序列化时,只保存对象的非静态成员变量,不能保存任何的成员方法和静态的成员变量。  2:如果一个对象的成员变量是一个对象,那么这个对象的数据成员也会被保存。  3:如果一个可序列化的对象包含对某个不可序列化的对象的引用,那么整 ...
(5)tcompanyinfo.java   import java.util.date;import javax.persistence.entity;import javax.persistence.generatedvalue;import javax.persistence.id;import javax.persistence.table;import org.hibernate.annotations.genericgenerator;import org.hibernate.annotations.parameter;   @entity@table(name=" ...
hibernatetemplate还提供一种更加灵活的方式来操作数据库,通过这种方式可以完全使用hibernate的操作方式。hibernatetemplate的灵活访问方式是通过如下两个方法完成: q      object execute(hibernatecallback action) q      list execute(hibernatecallback action) 这两个方法都需要一个hibernatecallback的实例,hibernatecallback实例可在任何有效的hibernate数据访问中使用。程序开发者通过hibernatecallback,可以完全使 ...
 ssh除了xml配置之外,还可以用标注式配置: (1)spring 与 hibernate annotation配置(entry)  http://zw7534313.iteye.com/blog/691546 (2)spring 与 hibernate annotation配置(dao)   http://zw7534313.iteye.com/blog/691529 (3)spring注解方式管理事务   http://zw7534313.iteye.com/blog/691398 (4)spring 与 hibernate annotation配置(applicationcont ...
http://bigcat.easymorse.com/?p=249   在ejb3.0 规范中 多对一与一对多的双向关系, 多对一(就是@manytoone注解的这端,是多端哦 不要搞混了)这端总是双向关联端的主题(owner)端, 而一对多端的关联注解为 @onetomany(mappedby=" " )其值是:多对一端的属性 实例三: (一对多)   create table "abc"."clazz"    ( "id" number(*,0) not null enable,  "clas ...
http://2625962-163-com.iteye.com/blog/243789   不同的地方:       
实例二:(主键sequence策略)   import javax.persistence.entity;import javax.persistence.generatedvalue;import javax.persistence.id; import org.hibernate.annotations.genericgenerator;import org.hibernate.annotations.parameter; @entitypublic class score {  @id @generatedvalue(generator=&q ...
实例一:一个对象的增删改查:   import java.math.bigdecimal;import java.util.date;import javax.persistence.entity;import javax.persistence.id;import org.hibernate.annotations.genericgenerator; @entitypublic class user2 implements java.io.serializable {  private integer id; private string name; private string se ...
错误原因分析:       首先看hql语句:        select pfp.tprofile from tprofileperson pfp left join fetch pfp.tprofile where pfp.tperson.personid = 114       此处我希望加载tprofileperson下的tprofile,而我使用了fetch来立即抓取tprofile,错误就在这里.如果你使用fetch,那么fetch左边的连接对象(拥有者)一定要出现在select后,例如将上面改为select pfp... 这样就会执行正常,因为使用了fetch,hiberna ...
首先说一句:是版本的问题! 我写的hql为: from department as d where d.employees.name='tom'; 运行时出现异常:org.hibernate.queryexception: illegal attempt to dereference collection 是因为:在上面的hql语句中,department的关联实体employees是一个集合,而不直接是一个employee实体。 在hibernate3.2.2以前的版本,hibernate会对关联实体自动使用隐式的inner join, 也就是说如下sql语句不会有任何问题 :f ...
3.4.5.  查询语言中的替换 你可以使用hibernate.query.substitutions在hibernate中定义新的查询符号. 例如: hibernate.query.substitutions true=1, false=0 将导致符号true和false在生成的sql中被翻译成整数常量.     2.在hibernate配置文 ...
hibernate查出来人部分数据基本上是数组,有的时候需要对象(但是该对象只包含一部分数据,只需要这一部分)   1.query q = session.createquery("select new user(name,pwd) from user");   list = q.list();   tran.commit();   2.query query = getsessionfactory().getcurrentsession().createsqlquery(hql).addscalar("title",hibernate.st ...
  //把fetch改成join就能解决 could not initialize proxy - the owning session was closed这个问题 inner join(内连接) left outer join(左外连接) right outer join(右外连接) full ...
public void createrolepermissionbysql(final string roleid,final string[] permids){                        gethibernatetemplate().execute(new hibernatecallback() {                public object doinhibernate(session session)                        throws hibernateexception, sqlexception {               ...
1.org.hibernate.lazyinitializationexception: could not initialize proxy - the owning session was closed   有关联的类中设置不延迟
http://www.cnblogs.com/ksyou/archive/2009/04/02/1428045.html 1.一级缓存:  session (似乎共用的一个session,但好象又不是) 2.二级缓存:  ehcache1.6                 二级缓存是缓存实体对象的   开启二级缓存,修改hibernate.cfg.xml文件  true  
  • 2009-07-23 11:41
  • 浏览 1822
使用c3p0的properties样例代码:hibernate.connection.driver_class = org.postgresql.driverhibernate.connection.url = jdbc:postgresql://localhost/mydatabasehibernate.connection.username = myuserhibernate.connection.password = secrethibernate.c3p0.min_size=5hibernate.c3p0.max_size=20hibernate.c3p0.timeout=1800hib ...
  • 2009-07-02 09:39
  • 浏览 1829
com.mysql.jdbc.communicationsexception: communications link failure due to underlying exception: ?? org.logicalcobwebs.proxool.proxoolexception: parsing failed.?? http://blog.sina.com.cn/s/blog_4a04ce7601009tin.html解决此问题: org.hibernate.hibernateexception:   proxool   provider   unable   to   load  ...
  • 2009-06-26 09:09
  • 浏览 2230
版本:proxool 0.9.1 这次配置出问题了,在hibernate.cfg.xml中少个property,如下: true 加上就好了。 它的配置: (1)在src下建proxool.xml
global site tag (gtag.js) - google analytics
网站地图