我是冬眠的新手。希望你们能帮我调试下面的错误,这真的让我发疯了。
我得到了一个名为CONTENT_WORKGROUP的表,它将映射到另一个名为CONTENT_WORKGROUP_ROLE的表。以下是表格结构和样本数据:
CONTENT_WORKGROUP
CONTENT_WORKGROUP_ROLE
)
P/S:一个用户工作组可以具有多个角色(Creator、Admin、Approver)。此工作组可以执行的函数(添加、编辑、删除)可以从CONTENT_WORKGROUP_ROLE.查询。
样本数据:
CONTENT_WORKGROUP
CM_WORKGROUP_ID WORKGROUP_ID ROLE_ID
1
2成品率
(3)成转率
CONTENT_WORKGROUP_ROLE
CM_WORKGROUP_ROLE_ID
1
2
3
4
5.商品、金融、商业、金融、金融、商业、金融、商业、金融等领域的商品、金融、金融、商业、金融、金融等行业的商品、金融、金融等行业的商品、商品、金融、金融等行业的
/T1666-1996商业专卖、转帐等
/T1777.7-1997商品、商品、商业、金融、金融、商业、金融、金融等领域的产品
但是,当我得到特定工作组持有的ContentWorkgroupRole集合时,我会得到错误。
11/23/10 15:28:56:053 SGT 00000039 SystemOut O 23/11/2010 15:28:56.053错误JDBCExceptionReporter - ORA-01722:无效编号
11/23/10 15:28:56:100 SGT 00000039 ServletWrappe E SRVE0068E:在servlet: action的服务方法中抛出的未捕获异常。引发的异常:无法初始化集合: corp.celcom.next.infochannel.model.ContentWorkgroup.contentWorkgroupRole#1
下面是我的hibernate映射文件: ContentWorkgroup.hbm.xml
<hibernate-mapping>
<class name="corp.celcom.next.infochannel.model.ContentWorkgroup" table="CM_WORKGROUP" >
<id name="cmWorkgroupId" type="long">
<column name="CM_WORKGROUP_ID" precision="15" scale="0" /> CM\_WORKGROUP CM\_WORKGROUP\_ID ContentWorkgroupRole.hbm.xml
<hibernate-mapping>
<class name="corp.celcom.next.infochannel.model.ContentWorkgroupRole" table="CM_WORKGROUP_ROLE" >
<id name="cmWorkgroupRoleId" type="long"> CM\_WORKGROUP\_ROLE\_ID CM\_WORKGROUP\_ROLE <many-to-one name="contentWorkgroup" class="corp.celcom.next.infochannel.model.ContentWorkgroup" fetch="select">
<column name="ROLE_ID" precision="15" scale="0" />
</many-to-one>在我的ACTION类中,上面提到的错误发生在这一行:Iterator =
用于( cw.getContentWorkgroupRole().iterator(); cw : contentWorkgroupList) {迭代器
while (iter.hasNext()) {
ContentWorkgroupRole role = (ContentWorkgroupRole) iter.next();
if (role.getFunctionId().equalsIgnoreCase(Constant.ADD))如果(role.getFunctionId().equalsIgnoreCase(Constant.EDIT)) myForm.setAllowEdit(真);如果(role.getFunctionId().equalsIgnoreCase(Constant.DELETE)) myForm.setAllowDelete(真);}}
奇怪的是,当我将ROLE_ID更改为Integer/Long (即1-Creator,2-Administrator)时,而不是使用字符串,它工作得很好!我不明白为什么,我的代码上有什么问题。
谢谢你的帮助。我已经花了一天时间来处理这个错误。谢谢!
发布于 2010-11-23 08:45:04
抱歉,显示器好像出了问题。我在这里再次写道:
ContentWorkgroup.hbm.xml
<hibernate-mapping>
<class name="corp.celcom.next.infochannel.model.ContentWorkgroup" table="CM_WORKGROUP" >
<id name="cmWorkgroupId" type="long">
<column name="CM_WORKGROUP_ID" precision="15" scale="0" />
<generator class="corp.celcom.next.util.MultipleTableGenerator" >
<param name="KEYTABLE_VALUE">CM_WORKGROUP</param>
<param name="KEYCOLUMN_VALUE">CM_WORKGROUP_ID</param>
</generator>
</id>
<property name="workgroupId" type="long">
<column name="WORKGROUP_ID" precision="15" scale="0" not-null="true" />
</property>
<property name="srId" type="string">
<column name="SR_ID" length="15" not-null="true" />
</property>
<property name="contentCategoryId" type="string">
<column name="CONTENT_CATEGORY_ID" length="40" not-null="true" />
</property>
<property name="roleId" type="string">
<column name="ROLE_ID" length="20" not-null="true" />
</property>
<set name="contentWorkgroupRole" table="CM_WORKGROUP_ROLE" inverse="true">
<key>
<column name="ROLE_ID" length="20" not-null="true" />
</key>
<one-to-many class="corp.celcom.next.infochannel.model.ContentWorkgroupRole" />
</set>
</class>
ContentWorkgroupRole.hbm.xml
<hibernate-mapping>
<class name="corp.celcom.next.infochannel.model.ContentWorkgroupRole" table="CM_WORKGROUP_ROLE" >
<id name="cmWorkgroupRoleId" type="long">
<column name="CM_WORKGROUP_ROLE_ID" precision="15" scale="0" />
<generator class="corp.celcom.next.util.MultipleTableGenerator">
<param name="KEYCOLUMN_VALUE">CM_WORKGROUP_ROLE_ID</param>
<param name="KEYTABLE_VALUE">CM_WORKGROUP_ROLE</param>
</generator>
</id>
<many-to-one name="contentWorkgroup" class="corp.celcom.next.infochannel.model.ContentWorkgroup" fetch="select">
<column name="ROLE_ID" precision="15" scale="0" />
</many-to-one>
<property name="menuId" type="string">
<column name="MENU_ID" length="40" not-null="true" />
</property>
<property name="functionId" type="string">
<column name="FUNCTION_ID" length="40" not-null="true" />
</property> 在我的ACTION类中,上面提到的错误发生在这一行:Iterator =
for(ContentWorkgroup cw : contentWorkgroupList)
{
Iterator iter = cw.getContentWorkgroupRole().iterator();
while (iter.hasNext()) {
ContentWorkgroupRole role = (ContentWorkgroupRole) iter.next();
if (role.getFunctionId().equalsIgnoreCase(Constant.ADD))
myForm.setAllowAdd(true);
if (role.getFunctionId().equalsIgnoreCase(Constant.EDIT))
myForm.setAllowEdit(true);
if (role.getFunctionId().equalsIgnoreCase(Constant.DELETE))
myForm.setAllowDelete(true);
}
}https://stackoverflow.com/questions/4254123
复制相似问题