关闭

hibernate生成cross join导致sybase不识别问题解决

244人阅读 评论(0) 收藏 举报
分类:

原文:http://blog.csdn.net/sjjbupt/article/details/8559886


升级了Hibernate到3.6.7,用的Sybase数据库,相同的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>

我的解决方法是Hibernate core里面已经有一种Sybase方言能够很好的匹配:

xy.hibernate.dialect=org.hibernate.dialect.SybaseASE15Dialect

对应的是:


换成这种方言就行了。问题解决





1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:160587次
    • 积分:1970
    • 等级:
    • 排名:千里之外
    • 原创:57篇
    • 转载:37篇
    • 译文:0篇
    • 评论:13条
    最新评论