参数绑定: Hibernate中对动态查询参数绑定提供了丰富的支持,那么什么是查询参数动态绑定呢?其实如果我们熟悉传统JDBC编程的话,我们就不难理解查询参数动态绑定,如下代码传统JDBC的参数绑定: PrepareStatement pre=connection.prepare(“select.....
分类:
Web程序 时间:
2015-01-13 15:43:30
阅读次数:
132
Hibernate查询
HQL vs EJBQL
1.NativeSQL>HQL>EJBQL(JPQL)>QBC(Query By Creteria)>QBE(Query By Example)
情景:
假设,Category表示的是论坛上的板块,Topic表示的是板块下面的主题,Msg表示的主题下的回复的帖子。
因而:Category和Topic之间是一对多。Topic和Msg是...
分类:
Web程序 时间:
2015-01-13 09:04:59
阅读次数:
203
public List getListScoreByJfEventId(Integer jfEventId){ List jfAuctionList=null; String hql ="select j.id,j.user,j.jfEvent,sum(j.score),j.status,j.cre...
分类:
其他好文 时间:
2015-01-12 14:39:32
阅读次数:
154
public int getMaxScoreByJfEventIdNumber(Integer jfEventId) { int numberValue=0; String hql = "from JfAuction where jfEvent.id =:jfEventId"; Finder fi....
分类:
其他好文 时间:
2015-01-12 14:37:53
阅读次数:
144
String hql ="select j from JfAuction j where 1=1 "; hql+=" and j.jfEvent.id ="; hql+=jfEventId; hql+=" order by j.score desc "; Query query = jfAucti....
分类:
其他好文 时间:
2015-01-12 14:32:46
阅读次数:
128
public JfAuction getMaxScoreByJfEventId(Integer jfEventId) { JfAuction jfAuction=null; String hql = "from JfAuction where jfEvent.id =:jfEventId and ....
分类:
其他好文 时间:
2015-01-12 14:28:06
阅读次数:
154
1:基本查询语句
from是最简单的语句,也是最基本的HQL语句。from关键字后紧跟持久化类的类名。
例如:
from Person 表明从Person持久化类中选出全部的实例。注意这里的实体类Person大小写敏感!
2:查询部分字段,组成新对象
select new Article(a.id,a.title,a.category) from Article a where...
分类:
其他好文 时间:
2015-01-10 16:45:21
阅读次数:
147
hibernate中对于数据库的Text数据类型不支持。
hibernate 使用hql查询包含text类型字段的时候很好。如果使用native sql也就是使用 createSQLQuery方法查询text类型的时候总是报错:
org.hibernate.MappingException: No Dialect mapping for JDBC type:-1
ato...
分类:
移动开发 时间:
2015-01-07 18:54:30
阅读次数:
165
@Override public List getCurrency(String code,String desc1,int offset, int size) { // TODO Auto-generated method stub List list=null; String hql="...
分类:
其他好文 时间:
2015-01-07 13:01:13
阅读次数:
116
使用hibernate时出现以下错误:org.hibernate.hql.ast.QuerySyntaxException: LogTaskEvents
is not mapped
原因1:hibernate的配置文件 *.hbm.xml文件没有添加的applicationContent.xml(或者相应的)文件中;
原因2:实体类LogTaskEvents 跟其相应的hib...
分类:
Web程序 时间:
2015-01-07 11:06:02
阅读次数:
180