List list = (List) session.createQuery("select s.id,s.username from Student s order by s.id desc").list();
for (int i = 0; i < list.size(); i++) {
Object[] objs = list.get(i);
for (int j = 0; j < objs.length; j++) {
System.out.println("------------------");
Object obj = objs[j];
System.out.println(obj);
}
}
聚合函数和分组查询
聚合函数,总记录数 注意返回的结果是long类型
Query query = session.createQuery("select count(*) FROM Student");
long count = (long) query.uniqueResult();
System.out.println(count);
Query query = session.createQuery("select o.customer,count(o) from Order o group by Customer having count (o) > 2");
List list = query.list();
for (int i = 0; i < list.size(); i++) {
Object[] objs = list.get(i);
System.out.println("-------------------------------");
for (int j = 0; j < objs.length; j++) {
System.out.println(objs[j]);
}
System.out.println("-------------------------------");
}
image.png
连接查询
INNER JOIN 在表中存在至少一个匹配时,INNER JOIN关键字返回行 LEFT OUT JOIN 关键字会从左表(table-name)返回所有的行即便右表(table-name)中没有匹配的行 RIGHT OUTER JOIN:关键字会在右表(table-name)返回所有的行,即使在左表(table-name)中没有匹配到行
image.png
隐式内连接,等效SQL隐式内连接
Query query = session.createQuery("from Customer c,Order o where c = o.customer");
List list = query.list();
for (int i = 0; i < list.size(); i++) {
Object[] objs = list.get(i);
System.out.println("----------------------");
for (int j = 0; j < objs.length; j++) {
Object obj = objs[j];
System.out.println(obj);
}
}
System.out.println(query.list());
内连接
List list = session.createQuery("from Customer c inner join c.orders").list();
for (int i = 0; i < list.size(); i++) {
System.out.println("---------------------");
Object[] objects = list.get(i);
for (int j = 0; j < objects.length; j++) {
Object obj = objects[j];
System.out.println(obj);
}
}
迫切内连接
List customers = session.createQuery("from Customer c inner join fetch c.orders").list();
for (int i = 0; i < customers.size(); i++) {
System.out.println("---------------");
Customer customer = customers.get(i);
if (customer.getOrders().size() == 0) {
System.out.println(customer);
}else{
Iterator iterator = customer.getOrders().iterator();
while (iterator.hasNext()) {
Order order = iterator.next();
System.out.println(customer +":" + order);
}
}
}
Query query = session.getNamedQuery("com.zzx.hibernate.domain.Customer.hql1");
List list = query.list();
for (int i = 0; i < list.size(); i++) {
System.out.println("--------------");
Iterator iterator = list.get(i).getOrders().iterator();
while (iterator.hasNext()) {
Order order = iterator.next();
System.out.println(list.get(i) + ":" +order);
}
}
Traits are a fundamental unit of code reuse in Scala. A trait encapsulates method and field definitions, which can then be reused by mixing them into classes. Unlike class inheritance, in which each c
版本:WebLogic Server 10.3
说明:%DOMAIN_HOME%:指WebLogic Server 域(Domain)目录
例如我的做测试的域的根目录 DOMAIN_HOME=D:/Weblogic/Middleware/user_projects/domains/base_domain
1.为了保证操作安全,备份%DOMAIN_HOME%/security/Defa
http://crazyjvm.iteye.com/blog/1693757 文中提到相关超时问题,但是又出现了一个问题,我把min和max都设置成了180000,但是仍然出现了以下的异常信息:
Client session timed out, have not heard from server in 154339ms for sessionid 0x13a3f7732340003
在Mysql 众多表中查找一个表名或者字段名的 SQL 语句:
方法一:SELECT table_name, column_name from information_schema.columns WHERE column_name LIKE 'Name';
方法二:SELECT column_name from information_schema.colum