1,聚集函数
2,分组
3,连接查询 / HQL是面向对象的查询
数据库中查询:
select e.id_, e.name_, d.name_ from employee e inner join department d on e.departmentId=d.id_;(内连接)
select e.id_, e.name_, d.name_ from employee e left outer join department d on e.departmentId=d.id_;(左外连接)
select e.id_, e.name_, d.name_ from employee e right outer join department d on e.departmentId=d.id_;(右外连接)
4,查询时使用参数
>> 方式一:使用'?'占位
>> 方式二:使用变量名
// 使用HQL查询
@Test
public void testHql2() throws Exception {
Session session = sessionFactory.openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
// ------------------------------------
String hql = null;//
// 1,聚集函数:count(),max(),min(),avg(),sum()
// 总数、最大、最小、平均、求和
// hql = "select count(e) from Employee e";// 返回的结果是Long型的
// hql = "select min(e.id) from Employee e";// 返回的结果是id的属性的类型
// Long result = (Long) session.createQuery(hql).uniqueResult();
// Number result = (Number) session.createQuery(hql).uniqueResult();
// System.out.println("总记录数:" + result.intValue());
// 2,分组:Group By ... Having
// hql = "select e.name,count(*) from Employee e group by e.name";
// hql = "select e.name,count(*) from Employee e group by e.name Having count(e.id)>1";
// hql = "select e.name,count(*) from Employee e where e.id<9 group by e.name Having count(e.id)>1";
// hql = "select e.name,count(*) " + //
// ---
// "from Employee e " + //
// "where e.id<9 " + //
// "group by e.name " + //
// "Having count(e.id)>1 " + //
// "order by count(e.id) asc";
// ---
// hql = "select e.name,count(*) as c " + //
// "from Employee e " + //
// "where e.id<9 " + //
// "group by e.name " + //
// "Having count(e.id)>1 " + // 在Having子句中不能使用列别名
// "Order by c asc";// 在Order by中可以使用列别名
// 3,连接查询 / HQL是面向对象的查询
// >> 内连接(inner关键字可以省略)
// hql = "select e.id,e.name,d.name from Employee e join e.department d";
// hql = "select e.id,e.name,d.name from Employee e inner join e.department d";
// >> 左外连接(outer关键可以省略)
// hql = "select e.id,e.name,d.name from Employee e left outer join e.department d";
// >> 右外连接(outer关键可以省略)
// hql = "select e.id,e.name,d.name from Employee e right outer join e.department d";
// 可以使过更方便的方法
// hql = "select e.id,e.name,e.department.name from Employee e";
// 4,查询时使用参数
// >> 方式一:使用'?'占位
// hql = "from Employee e where e.id between ? And ?";
// List
1,聚集函数
2,分组
3,连接查询 / HQL是面向对象的查询
数据库中查询:
select e.id_, e.name_, d.name_ from employee e inner join department d on e.departmentId=d.id_;(内连接)
select e.id_, e.name_, d.name_ from employee e left outer join department d on e.departmentId=d.id_;(左外连接)
select e.id_, e.name_, d.name_ from employee e right outer join department d on e.departmentId=d.id_;(右外连接)
4,查询时使用参数
>> 方式一:使用'?'占位
>> 方式二:使用变量名
5,使用命名查询
6,update与delete,不会通知Session缓存
在update或delete后,需要refresh(obj)一下以获取最新的状态
隔离级别中文 隔离级别英文 对应的整数表示
读未提交 READ UNCOMMITED 1
读已提交 READ COMMITED 2
可重复读 REPEATABLE READ 4
串行化(不可并发) SERIALIZEABLE 8
=:idMin and e.id<=:idMax
]]>
// 使用HQL查询
@Test
public void testHql2() throws Exception {
Session session = sessionFactory.openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
// ------------------------------------
String hql = null;//
// 1,聚集函数:count(),max(),min(),avg(),sum()
// 总数、最大、最小、平均、求和
// hql = "select count(e) from Employee e";// 返回的结果是Long型的
// hql = "select min(e.id) from Employee e";// 返回的结果是id的属性的类型
// Long result = (Long) session.createQuery(hql).uniqueResult();
// Number result = (Number) session.createQuery(hql).uniqueResult();
// System.out.println("总记录数:" + result.intValue());
// 2,分组:Group By ... Having
// hql = "select e.name,count(*) from Employee e group by e.name";
// hql = "select e.name,count(*) from Employee e group by e.name Having count(e.id)>1";
// hql = "select e.name,count(*) from Employee e where e.id<9 group by e.name Having count(e.id)>1";
// hql = "select e.name,count(*) " + //
// ---
// "from Employee e " + //
// "where e.id<9 " + //
// "group by e.name " + //
// "Having count(e.id)>1 " + //
// "order by count(e.id) asc";
// ---
// hql = "select e.name,count(*) as c " + //
// "from Employee e " + //
// "where e.id<9 " + //
// "group by e.name " + //
// "Having count(e.id)>1 " + // 在Having子句中不能使用列别名
// "Order by c asc";// 在Order by中可以使用列别名
// 3,连接查询 / HQL是面向对象的查询
// >> 内连接(inner关键字可以省略)
// hql = "select e.id,e.name,d.name from Employee e join e.department d";
// hql = "select e.id,e.name,d.name from Employee e inner join e.department d";
// >> 左外连接(outer关键可以省略)
// hql = "select e.id,e.name,d.name from Employee e left outer join e.department d";
// >> 右外连接(outer关键可以省略)
// hql = "select e.id,e.name,d.name from Employee e right outer join e.department d";
// 可以使过更方便的方法
// hql = "select e.id,e.name,e.department.name from Employee e";
// 4,查询时使用参数
// >> 方式一:使用'?'占位
// hql = "from Employee e where e.id between ? And ?";
// List
public class HttpClientUtils
{
public static CloseableHttpClient createSSLClientDefault(CookieStore cookies){
SSLContext sslContext=null;
try
{
sslContext=new SSLContextBuilder().l
对于JAVA的join,JDK 是这样说的:join public final void join (long millis )throws InterruptedException Waits at most millis milliseconds for this thread to die. A timeout of 0 means t
在网站项目中,没必要把公用的函数写成一个工具类,有时候面向过程其实更方便。 在入口文件index.php里添加 require_once('protected/function.php'); 即可对其引用,成为公用的函数集合。 function.php如下:
<?php /** * This is the shortcut to D
这篇日志是我写的第三次了 前两次都发布失败!郁闷极了!
由于在web开发中常常用到这一部分所以在此记录一下,呵呵,就到备忘录了!
我对于登录信息时使用session存储的,所以我这里是通过实现HttpSessionAttributeListener这个接口完成的。
1、实现接口类,在web.xml文件中配置监听类,从而可以使该类完成其工作。
public class Ses
Spring Boot 1.3.0.M1于6.12日发布,现在可以从Spring milestone repository下载。这个版本是基于Spring Framework 4.2.0.RC1,并在Spring Boot 1.2之上提供了大量的新特性improvements and new features。主要包含以下:
1.提供一个新的sprin