团队升级一次不容易,总要找到足够的理由或者借口:查询语法的全面增强;真正彻底的or映射;性能的提升是三个的主要理由。另外,买一送一的,还有四个暂时不是理由的理由。
查询语法全面增强
hql,native sql ,criteria都有大幅增强,不再有太多无法完成需要sql辅助的地方
1.hql语法增强
使用antlr的作为语法引擎
支持subquery,distinct, nullif,case ,cast,having count(*)在内的绝大部分sql语法
支持bulk-update,bulk-delete 语法
"update customer set name = :newname where name = :oldname";
2.native sql增强
2.0时的native基本上是流血上市,中看不中用的。3.0时才基本可用。
3. 非完整对象的查询结果返回map 而不是array.
2.0时按array[0],array[1]访问查询结果根本是无人敢用的语法,map的好处是可以按名称取值
" select new map(goods.goodsno as goodsno,goods.code as code) from goods goods"
map goods =(map)list.get(0);
strng code = (string)goods.get("code");
真正的or映射
完美支持三种o/r典型映射及其混合
discrim(整个继承树在同一个表,通过discrim列区分不同的子类)
unionclass(每个子类一个表,每个表拥有全部属性)
joinclass(每个父类每个子类各有一个表,父类的属性在父表,子类的表只包含子类的属性)
4.discrim支持formula虚拟列做标识符
不再需要一个单独的discriminator列,可以通过对其他列的计算得出子类的标识符
<discriminator type="int"
formula="case when company is null then 0 when company = 'jboss' then 1 else 2 end"/>
5.union class支持
<class name="being" abstract="true">
<id name="id" unsaved-value="0" column="bid">
<generator class="increment"/>
</id>
<property name="identity" column="ident"/>
<union-subclass name="human" table="aliens">
<property name="sex" column="sex"/>
</union-subclass>
</class>
关键性能升级
6.column-level lazy fecth
2.0的时候只能对one to many的列 lazy fecth,结果找一个对象经常藤连瓜瓜连藤找出10来个对象出来,很恐怖。3.0终于没有这个恶梦了。
买一送一的new feactures
1.ejb3 annotation, 取代xml-base的hbm文件。
2.handwrite crud sql, 向ibatis的地盘讨饭。
3.持久化xml ,除了pojo外,还支持xml的持久化,方便webservice, esb类的应用。
4.one class map to mutible table,打破 one table,one object的范式。
闽公网安备 35060202000074号