该帖已经被评为精华帖
|
|
---|---|
作者 | 正文 |
发表时间:2004-01-13
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2004-01-13
1、不需要复杂的配置文件;
2、可以很方便的对项目进行重构; 3、良好的性能; 4、支持复杂的查询包括统计查询;[/u] |
|
返回顶楼 | |
发表时间:2004-01-13
hibernate不满足你的要求么?
第4条可能有些困难! |
|
返回顶楼 | |
发表时间:2004-01-13
hibernate是一个很不错的框架,但是我觉得有两个问题
1、过分的依赖于配置文件,不借助其它工具很难处理; 2、查询语句基于字符串,对于项目重构很不利。 我觉得如果我们能够使用程序语言来书写sql查询和更新语句会更好,我是一个喜欢简单的人,看到那么多的配置文件我就头疼~_~. |
|
返回顶楼 | |
发表时间:2004-01-13
其实,第四条也不是不能实现,那只是思路的问题,我正在尝试做一个数据持久化框架,已经可以实现比较复杂的统计查询,目前正在做最后的测试,测试完了以后,我将公布导网上。
其实我学java也没多久,有很多东西不是很懂。这里气氛很不错,可以看得出站长技术也不错,而且对网站很热心。为大家提供了一个可以进行技术流的场所值得大家表扬。也希望能够有高手愿意做我的技术顾问,使我能够尽快的完善第一版。 |
|
返回顶楼 | |
发表时间:2004-01-13
public class InnerJionQuery extends Query { public Field customerID; public Field orderID; public Field companyName; public Field contactName; public Field orderDate; public Field employeeID; public InnerJionQuery();{ Customers customers = (Customers); SessionFactory.getResourceRef(Customers.class);; Orders orders = (Orders);SessionFactory.getResourceRef(Orders.class);; customerID =customers.customerID; companyName = customers.companyName; contactName = customers.contactName; orderID= orders.orderID; orderDate =orders.orderDate; employeeID =orders.employeeID; select_all();; from(customers.inner_jion(orders);.on(customers.customerID.eq(orders.customerID);););; order_by(customerID.asc(););; } public static void main(String[] args); { InnerJionQuery testQuery = (InnerJionQuery);SessionFactory.getResource(InnerJionQuery.class);; SessionContext dbc; try { dbc = SessionFactory.getContext();; try{ testQuery.setAbsolutePage(1);; testQuery.setPageSize(5);; dbc.openQuery(testQuery,testQuery.companyName.like("a%");.and(testQuery.orderID.gte(10926););,testQuery.orderID.asc();._(testQuery.companyName););; while (testQuery.next(););{ System.out.print(testQuery.customerID.getValue();.getString();+" ");; System.out.print(testQuery.orderID.getValue();.getInt();+" ");; System.out.println(testQuery.orderDate.getValue();.getString(););; } }finally{ try { dbc.setComplete();; }catch (DudoJException e1); { e1.printStackTrace();; } } } catch (SqlException e); { e.printStackTrace();; } catch (Exception e); { e.printStackTrace();; } } } |
|
返回顶楼 | |
发表时间:2004-01-13
public class GroupByQuery extends Query { public Field maxFreight; public Field minFreight; public Field avgFreight; public Field countFreight; public Field countBigFreight; public Field sumFreight; public Field stdevFreight; public Field stdevpFreight; public Field varFreight; public Field varpFreight; public Field orderID; public GroupByQuery();{ Orders orders = (Orders);SessionFactory.getResourceRef(Orders.class);; orderID = orders.orderID; maxFreight = max(orders.freight);.div(10);.toField();; minFreight = CalcField.create(min(orders.freight.add(70);););; avgFreight = CalcField.create(avg(distinct(orders.freight);););; countFreight = CalcField.create(count(orders.freight););; countBigFreight = CalcField.create(count_big(orders.freight););; sumFreight = CalcField.create(sum(orders.freight););; stdevFreight = CalcField.create(stdev(orders.freight););; stdevpFreight = CalcField.create(stdevp(orders.freight););; varFreight = CalcField.create(var(orders.freight););; varpFreight =CalcField.create(varp(orders.freight););; select_all();; from(orders);; group_by(orderID);; having(minFreight.gt(1););; } public static void main(String[] args); { SessionContext dbc; try { dbc = SessionFactory.getContext();; try{ dbc = SessionFactory.getContext();; GroupByQuery test = (GroupByQuery);SessionFactory.getResource(GroupByQuery.class);; while (test.next(););{ System.out.print(test.orderID.getValue();.getString();+" ");; System.out.print(test.maxFreight.getValue();.getString();+" ");; System.out.print(test.minFreight.getValue();.getString();+" ");; System.out.print(test.avgFreight.getValue();.getString();+" ");; System.out.print(test.countFreight.getValue();.getString();+" ");; System.out.print(test.countBigFreight.getValue();.getString();+" ");; System.out.println(test.sumFreight.getValue();.getString();+" ");; } }finally{ try { dbc.setComplete();; }catch (Exception e1); { e1.printStackTrace();; } } } catch (SqlException e); { e.printStackTrace();; } catch (Exception e); { e.printStackTrace();; } } } |
|
返回顶楼 | |
发表时间:2004-01-13
引用 1、过分的依赖于配置文件,不借助其它工具很难处理;
2、查询语句基于字符串,对于项目重构很不利。 1、配置文件复杂吗?你用过EJB就知道什么叫做复杂了。 2、 Hibernate2.1的 Criteria Queries |
|
返回顶楼 | |
发表时间:2004-01-13
配置文件是一方面,hibernate我用的不是很熟,无权做出更多的评价。我看到的hibernate构造的查询语句都是基于字符串的,虽然说是基于对象的查询,但是查询语句中的对象已经和java中的对象有所区别,那只是个概念而已,如果在项目中间,要更改某个类名,是否要手动逐个更改相关查询?至少目前的ide都不理会字符串中的类名。不知我说的对不对。
|
|
返回顶楼 | |
发表时间:2004-01-13
你说的那是HQL,你可以不用HQL,改用Criteria Queries,只是Criteria Queries的功能还比较弱,实现不了类似HQL那么强大的如统计查询的功能。
|
|
返回顶楼 | |