Fight With Me!!!

导航

随笔分类 -  Hibernate

上一页 1 2 3 4 5 下一页

hibernate Criteria中or和and的用法
摘要:用来组合一组逻辑或【or】条件的方法 Java代码 Restrictions.disjunction(); Java代码 Java代码 用来组合一组逻辑与【and】条件的方法 Java代码 Restrictions.conjunction(); Java代码 Java代码 注释掉部分的代码,查询结果 阅读全文

posted @ 2016-08-17 20:30 nickTimer

Hibernate高效查询,只查询部分/指定字段
摘要:公司使用 [java] view plain copy print? DetachedCriteria detachedCriteria = DetachedCriteria.forClass(PeBulletin.class); detachedCriteria.createAlias("enum 阅读全文

posted @ 2016-08-12 09:09 nickTimer

Hibernate自定义字段查询
摘要:关于Hibernate自定义字段查询的方法,网上有很多,我这里就不详细写了,只把几个查询方法的注意事项说明一下。 废话少说, 进入正题: 假设有2个实体对象,Institution和User,结构与配置如下: @Entity(value = "Institution") @Table(name = 阅读全文

posted @ 2016-08-12 09:07 nickTimer

hibernate -- 分页模糊查询中setParameter 和setParameterList
摘要:在分页模糊查询中碰到setParameter 和setParameterList这两个方法 setParameter 以前就只会用setParameter(int arg,String str),我用到了from table A where 1=1 and ... like ? 还可以用另外一种方法 阅读全文

posted @ 2016-06-16 13:13 nickTimer

Remember that ordinal parameters are 1-based!
摘要:问题发生的原因是:hql语句里不需要参数,却添加了一个参数,删掉添加参数的语句就可以了! 阅读全文

posted @ 2016-06-11 10:03 nickTimer

hibernate annotation配置经验
摘要:1.将annotation写在entity类文件的get方法上面 阅读全文

posted @ 2016-05-29 16:49 nickTimer

使用hibernate annotation 为非空列加上默认值
摘要:在网上查了很多资料都没找到如何为非空列加上默认值 以前的做法是给字段一个初始值,加上dynamic-insert属性 换了annotation了以后没有找到如何设置dynamic-insert属性 但是,最后经过测试发现hibernate annotation 根本不用设置dynamic-inser 阅读全文

posted @ 2016-05-29 16:24 nickTimer

The dialect was not set. Set the property hibernate.dialect
摘要:The dialect was not set. Set the property hibernate.dialect load hibernate.cfg.xml 出现了问题 获取配置信息代码应该这样写 Configuration conf = new Configuration().config 阅读全文

posted @ 2016-05-29 16:15 nickTimer

JdbcTemplate查询数据 三种callback之间的区别
摘要:JdbcTemplate针对数据查询提供了多个重载的模板方法,你可以根据需要选用不同的模板方法。 如果你的查询很简单,仅仅是传入相应SQL或者相关参数,然后取得一个单一的结果,那么你可以选择如下一组便利的模板方法: int queryForInt(String sql) int queryForIn 阅读全文

posted @ 2016-05-29 16:08 nickTimer

启动PL/SQL Developer 报字符编码不一致错误 Database character set (AL32UTF8) and Client character set (ZHS16GBK) are different. Character set conversion may cause unexpected results. Note: you can set the client
摘要:今天写hibernate时候遇到一些异常 代码: 出现异常情况: 出现以上原因是Session关闭 如果不是使用的SessionFactory.getSession()来获得Session。 而是使用SessionFactory.getCurrentSession()方法来获得Session时,当事 阅读全文

posted @ 2016-05-29 14:26 nickTimer

hibernate 中id生成策略
摘要:数据库的设计和操作中,我们通常会给表建立主键。 主键,可以分为自然主键和代理主键。 自然主键表示:采用具有业务逻辑含义的字段作为表的主键。比如在用户信息表中,采用用户的身份证号码作为主键。但是这样一来,随着业务逻辑的变化,主键就有可能要更改。比如,假设哪天身份证号码升级成19,2位,那。。。。。。。 阅读全文

posted @ 2016-05-29 14:12 nickTimer

配置hibernate根据实体类自动建表功能
摘要:Hibernate支持自动建表,在开发阶段很方便,可以保证hbm与数据库表结构的自动同步。 如何使用呢?很简单,只要在hibernate.cfg.xml里加上如下代码 Xml代码<property name="hbm2ddl.auto">update</property> update:表示自动根据 阅读全文

posted @ 2016-05-29 13:51 nickTimer

createSQLQuery与createQuery的区别
摘要:本文原址 : http://stta04.javaeye.com/blog/377633hibernate 中createQuery与createSQLQuery 昨晚帮同事看代码到凌晨2点多,今早6点醒来发现他发来信息说报空指针错误,实在无法入睡,起来自己测试了一下,控制台还真的报: 2009-4 阅读全文

posted @ 2016-05-29 13:27 nickTimer

No Hibernate Session bound to thread, and configuration does not allow
摘要:今天晚上挺悲催的,遇到了这个问题花费我很长时间,现在总结如下: 到这这种情况的发生有两种情况: 1,没有配置事物只要在Spring配置文件中添加如下代码: 然后在DAO程序前面加上@Transactional即可。2,连接数据的配置是否正确,如果连接字符串不正确的话,就不能够创建SessionFac 阅读全文

posted @ 2016-05-29 13:20 nickTimer

hibernate实体的几种状态:
摘要:hibernate实体的几种状态: 实体的生命周期中,实体主要经过瞬时(Transient),托管(Attatched或Managed),游离(Detached)和销毁(Removed)四个状态. 瞬时状态:是指对象被new之后尚未保存到数据库,一旦服务器停止,JVM会回收它所占的内存资源,此时对象 阅读全文

posted @ 2016-05-28 17:06 nickTimer

many-to-one和one-to-many的配置比较
摘要:many-to-one配置: <many-to-one name="dailyCatalog" column="daily_catalog_id" class="com.tyloo.po.DailyCatalog" fetch="join" lazy="false" /> one-to-many配置 阅读全文

posted @ 2016-05-28 17:00 nickTimer

one-to-many many-to-one配置解释
摘要:one-to-many放在某个文件的配置中,表示这个文件是ONE的一方, 同样的many-to-one放在某个文件的配置中,表示这个文件是many的一方。 one-to-many放在某个文件的配置中,表示这个文件是ONE的一方, 同样的many-to-one放在某个文件的配置中,表示这个文件是man 阅读全文

posted @ 2016-05-28 16:59 nickTimer

java.lang.ClassNotFoundException: javax.persistence.EntityListeners
摘要:Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/EntityListeners at org.hibernate.cfg.annotations.reflection.JPAMetadataPr 阅读全文

posted @ 2016-05-28 16:55 nickTimer

mappingResources,annotatedClasses(映射)
摘要:这两个是有本质区别的,光看名字也能看出来,哈哈,好了,入正题: mappingResources用于指定少量的hibernate配置文件像这样 Xml代码 1 2 3 4 5 6 7 <property name="mappingResources"> <list> <value>WEB-INF/c 阅读全文

posted @ 2016-05-28 16:53 nickTimer

HibernateTemplate 查询
摘要:Spring中常用的hql查询方法getHibernateTemplate()上 一、find(String queryString); 示例:this.getHibernateTemplate().find("from bean.User"); 返回所有User对象 二、find(String q 阅读全文

posted @ 2016-05-28 16:36 nickTimer

上一页 1 2 3 4 5 下一页