publicclassTest{
/** *//** *@paramargs
*@throwsQueryException
*/
publicstaticvoidmain(String[] args)throwsQueryException{
/** *//** * 修改了配置文件用于测试hibernate整合spring是否正常
*/ ApplicationContext context=newFileSystemXmlApplicationContext("src/applicationContext.xml");
context.getBean("sessionFactory");
StudentServer server=(StudentDAO) context.getBean("studentDAO");
/**//*Student stu = new Student();
stu.setStuname("qq22222222");
stu.setAge(56);
stu.setSex("男");
stu.setPhone(555);
//server.addStudentByCondition(stu);
server.addStudent(stu);*/ Listlist=server.getStudent("s","男");
for(Student stu : list){
System.out.println(stu.getStuname());
}
/** *//** * 使用select 查询字段
List list = server.getStudent("s", "男");
for(Object[] c : list){
for(Object a : c){
System.out.print(a + "\t");
}
System.out.println();
}
*/ }}
查询提供了两种方式,一种是使用DAODelegate提供的查询(这和普通的hibernate一样的)
第二种方式是 封装了一个查询类HqlQuery 具体使用例子中有了
对框架提出以下几点:
1、我现在想把AbstractService 这个类在spring注入的时候设置成为静态的 可以提高效率 但不知会有别的什么影响?? 还请哪个朋友指点一下 十分感谢
2、StudentServer 这个接口 和StudentDAO这个类 是一一对应的 StudentDAO这个必须实现接口的方法 而接口中就定义和业务相关的方法 StudentDAO在spring中注入 调用时候使用StudentServer 指向子类
但这样的每在StudentServer 增加一个业务方法就要在dao实现类中添加一个 不知道这样好不好??
还请朋友们帮忙看下
3、因为还没有涉及到web开发 但查询中缺少分页查询,正在整理,有好的分页组件请大家分享下我的邮箱
sunxianchao@gmail.com
有什么好的建议和提议请大家留言 十分感谢!!!
http://exs.mail.qq.com/cgi-bin/downloadfilepart?svrid=12&fid=644bd873e37da73f4ceeef5962b2eeae94fa6298069572c4
提取码:20dc1eb4
希望可以提出您的宝贵意见
posted on 2007-12-10 13:41 LifeNote 阅读(1646) 评论(7) 编辑 收藏 所属分类: Java 、Hibernate 、Spring