十年树木的博客

生活不要对自己和别人太严肃,学会轻松幽默的生活。

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

原文: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

对应的是:


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





阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

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

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭