Listspes = session.createQuery("select spe from Special spe").list();
3.模糊查询:
List stus = session.createQuery("from Student where name like '%张%'").list();List
4.基于?的条件的查询,特别注意:jdbc设置参数的最小下标是1,hibernate是0
Liststus = session.createQuery("from Student where name like ?").setParameter(0, "%李%").list();
5.还可以基于别名进行查询,使用:xxx来说明别名的名称
List stus = session.createQuery("from Student where name like :name and sex=:sex").setParameter("name", "%刘%").setParameter("sex", "男").list();
6.使用uniqueResult可以返回唯一的一个值
Long stus = (Long)session.createQuery("select count(*) from Student where name like :name and sex=:sex").setParameter("name", "%刘%").setParameter("sex", "男").uniqueResult();
Student stu = (Student)session.createQuery("select stu from Student stu where id=:id")
.setParameter("id", 1).uniqueResult();
7.基于投影的查询,通过在列表中存储一个对象的数组
List
8.如果对象中相应的导航对象,可以直接导航完成查询
List stus = session.createQuery("select stu from Student stu where stu.classroom.name=? and stu.name like ?").setParameter(0, "计算机教育班").setParameter(1, "%张%").list();
9.可以使用in来设置基于列表的查询,此处的查询需要使用别名进行查询
* 特别注意,使用in的查询必须在其他的查询之后
Liststus = session.createQuery("select stu from Student stu where stu.name like ? and stu.classroom.id in (:clas)").setParameter(0, "%张%").setParameterList("clas", new Integer[]{1,2}).list();
List stus = session.createQuery("select stu from Student stu where stu.classroom.id in (:clas)").setParameterList("clas", new Integer[]{1,2}).setFirstResult(0).setMaxResults(15).list();
11.可以通过is null来查询为空的对象,和sql一样不能使用=来查询null的对象
Liststus = session.createQuery("select stu from Student stu where stu.classroom is null").setFirstResult(0).setMaxResults(15).list();
Liststus = session.createQuery("select cla.name,count(stu.classroom.id) from Student stu right join stu.classroom cla group by cla.id").list();
13.直接可以使用new XXObject完成查询,注意,一定要加上Object的完整包名
* 这里使用的new XX,必须在对象中加入相应的构造函数
注意:需要新建一个实体类,没有存储意义,但是具有传输意义
Liststus = session.createQuery("select new org.zttc.itat.model.StudentDto" +"(stu.id as sid,stu.name as sname,stu.sex as sex,cla.name as cname,spe.name as spename) " +"from Student stu left join stu.classroom cla left join cla.special spe").list();
14.having是为group来设置条件的
Liststus = session.createQuery("select spe.name," +"(count(stu.classroom.special.id)) from Student stu right join " +"stu.classroom.special spe group by spe having count(stu.classroom.special.id)>150").list();
having是为group来设置条件的
Liststus = session.createQuery("select stu.sex,spe.name," +"(count(stu.classroom.special.id)) from Student stu right join " +"stu.classroom.special spe group by spe,stu.sex").list();
什么是Hessian
The Hessian binary web service protocol makes web services usable without requiring a large framework, and without learning yet another alphabet soup of protocols. Because it is a binary p
在Spark Shell上,通过创建HiveContext可以直接进行Hive操作
1. 操作Hive中已存在的表
[hadoop@hadoop bin]$ ./spark-shell
Spark assembly has been built with Hive, including Datanucleus jars on classpath
Welcom
JMS Message Delivery Reliability and Acknowledgement Patterns
http://wso2.com/library/articles/2013/01/jms-message-delivery-reliability-acknowledgement-patterns/
Transaction and redelivery in
转载请出自出处:http://eksliang.iteye.com/blog/2177567 一、游标
数据库使用游标返回find的执行结果。客户端对游标的实现通常能够对最终结果进行有效控制,从shell中定义一个游标非常简单,就是将查询结果分配给一个变量(用var声明的变量就是局部变量),便创建了一个游标,如下所示:
> var