将hibernate升级后相同的hql竟然生成了不同的sql。以下分别是hql和新老版本生成的sql。我的sybase15不识别crossover,只好另想办法。
select new com.abc.boor.model.InformationView(c.id,a.id,a.title,a.content,rtrim(a.type),rtrim(a.level),a.status,a.processMemberId,a.createTime,c.name,o.name,a.createMemberId,m.name,a.flag) from Information a,Member c,Member m,Organize o where a.processMemberId= ? and a.status='2' and c.id = a.processMemberId and a.createMemberId =m.id and a.createOrganizeId=o.id order by a.createTime DESC
select member1_.BMCID as col_0_0_, informatio0_.AICID as col_1_0_, informatio0_.AICTIT as col_2_0_, informatio0_.AICCNT as col_3_0_, rtrim(informatio0_.AICTYP) as col_4_0_, rtrim(informatio0_.AICLVL) as col_5_0_, informatio0_.AICSTS as col_6_0_, informatio0_.AICPMID as col_7_0_, informatio0_.AICCTIM as col_8_0_, member1_.BMCNAM as col_9_0_, organize3_.BOCNAM as col_10_0_, informatio0_.AICCMID as col_11_0_, member2_.BMCNAM as col_12_0_, informatio0_.AICFLA as col_13_0_ from AIC informatio0_, BMC member1_, BMC member2_, BOC organize3_ where informatio0_.AICPMID=? and informatio0_.AICSTS='2' and member1_.BMCID=informatio0_.AICPMID and informatio0_.AICCMID=member2_.BMCID and informatio0_.AICCOID=organize3_.BOCID order by informatio0_.AICCTIM DESC
select member1_.BMCID as col_0_0_, informatio0_.AICID as col_1_0_, informatio0_.AICTIT as col_2_0_, informatio0_.AICCNT as col_3_0_, rtrim(informatio0_.AICTYP) as col_4_0_, rtrim(informatio0_.AICLVL) as col_5_0_, informatio0_.AICSTS as col_6_0_, informatio0_.AICPMID as col_7_0_, informatio0_.AICCTIM as col_8_0_, member1_.BMCNAM as col_9_0_, organize3_.BOCNAM as col_10_0_, informatio0_.AICCMID as col_11_0_, member2_.BMCNAM as col_12_0_, informatio0_.AICFLA as col_13_0_ from AIC informatio0_ cross join BMC member1_ cross join BMC member2_ cross join BOC organize3_ where informatio0_.AICPMID=? and informatio0_.AICSTS='2' and member1_.BMCID=informatio0_.AICPMID and informatio0_.AICCMID=member2_.BMCID and informatio0_.AICCOID=organize3_.BOCID order by informatio0_.AICCTIM DESC
解决办法:
1.src下新建org..MySybaseDialect包。
2.包下新建MySybaseDialect类。
3.类写为:
package org.MySybaseDialect; public class MySybaseDialect extends org.hibernate.dialect.SybaseDialect { @Override public String getCrossJoinSeparator() { return ", "; } }
4.applicationContext.xml做如下配置:
<prop key="hibernate.dialect"> org.MySybaseDialect.MySybaseDialect </prop> |