语法:
select 对象.属性名
from 对象
where 过滤条件
group by 对象.属性名
having 分组条件
order by 对象.属性名
实体对象查询
from 对象 对象别名 where 条件
eg:
Query q = session.createQuery("from Employee emp");
emplist = q.list();
HQL参数绑定机制:
1.绑定?占位符
eg:
Query q = session.createQuery("from Employee emp where sex =?");
q.setParameter(0,"男");
emplist = q.list();
1.绑定:parameter占位符
eg:
Query q = session.createQuery("from Employee emp where sex =:sex");
q.setParameter("sex","男");
emplist = q.list();
Spring :
1.使用BeanFactory管理bean ,在getBean方法之前,不会实例化对象
eg:装载bean:
Resource resource = new ClassPathResource("applicationContext.xml"); //装载配置文件
BeanFactory factory = new XmlBeanFactory(resource);
Test test = (Test)factory.getBean("test");