读书人

hibernate 未明确定义列异常

发布时间: 2012-08-31 12:55:03 作者: rapoo

hibernate 未明确定义列错误
今天在项目中碰到这个错误,经过初步调试找到了错误的位置,将打印出的SQL语句拿到PL/SQL里面执行,发现出现了如下问题
select
this_.Bdz_id as Bdz1_480_7_,
this_.gis_id as gis2_480_7_,
this_.jg_id as jg3_480_7_,
this_.bianma as bianma480_7_,
this_.mingzi as mingzi480_7_,
this_.userflag as userflag480_7_,
this_.nosf6 as nosf7_480_7_,
this_.bdz_id as bdz1_480_7_,
对于bdz_id字段查询了两次,所以在外层再次嵌套查询的时候会出现未明确定义列,出现此问题的原因是什么呢?经过思考,只可能是配置文件出错,详细检查后发现
<composite-id>
<key-property name="bdzId" type="java.lang.Short">
<column name="Bdz_id" />
</key-property>
<key-property name="gisId" type="java.lang.Short">
<column name="gis_id" />
</key-property>
</composite-id>
而在多对一的配置时候
<many-to-one name="bdz" insert="false" update="false" outer-join="true">
<column name="bdz_id" />
</many-to-one>
所以才会出现查询了两次bdz_id,只要把两处改成一样即可

读书人网 >软件架构设计

热点推荐