freedomstyle 2008-12-12 17:09
浏览 1078
已采纳

No row with the given identifier exists

     org.hibernate.ObjectNotFoundException: No row with the given identifier exists:       [OfficeWH.entity.RoleRight#101]

 

     我在做一个关联表查询的时候,它报这个错误,请大家指正一下,这样的错误该怎样去解决!!有哪些情况会引发这一的错误呢!!一直报这个错误!!我估计是hibernate配置的关系有问题吧!!

下面有一张我数据库截图的图片,首先UserInfo表是用户登录,没问题!!   然后查出了SysRole表中  用户对应的角色,然后表关联到  RoleRight这个表,  根据这个角色查SysFun中对应的权限!!!

 

当然这个UserInfo还关联了其他的很多张表,它和RoInfo表配置的关系如下:   麻烦大家帮我看看,感激不尽!!!

  
      <class name="OfficeWH.entity.UserInfo" table="UserInfo" schema="dbo" catalog="MyOffice">
        <id name="userId" type="java.lang.String">
            <column name="UserId" length="50">
            <generator class="native">
        </id>
        <many-to-one name="userState" class="OfficeWH.entity.UserState" fetch="select">
            <column name="UserStateId" not-null="true">
        </many-to-one>
        //这里就是和  RoleInfo对应的关系配置文件
        <many-to-one name="roleInfo" column="RoleId" class="OfficeWH.entity.RoleInfo" fetch="select" lazy="false">
        </many-to-one>
        
        <property name="userName" type="java.lang.String">
            <column name="UserName" length="50" not-null="true">
        </property>
        <property name="password" type="java.lang.String">
            <column name="Password" length="50" not-null="true">
        </property>
        <property name="departId" type="java.lang.Integer">
            <column name="DepartId" not-null="true">
        </property>
        <property name="gender" type="java.lang.Integer">
            <column name="Gender" not-null="true">
        </property>
        <set name="fileInfos">
            <key>
                <column name="FileOwner" length="50" not-null="true">
            </key>
            <one-to-many class="OfficeWH.entity.FileInfo">
        </set>
        <set name="schedules">
            <key>
                <column name="CreateUser" length="50" not-null="true">
            </key>
            <one-to-many class="OfficeWH.entity.Schedule">
        </set>
        <set name="readCommonMessages">
            <key>
                <column name="UserId" length="50" not-null="true">
            </key>
            <one-to-many class="OfficeWH.entity.ReadCommonMessage">
        </set>
        <set name="manualSigns">
            <key>
                <column name="UserId" length="50" not-null="true">
            </key>
            <one-to-many class="OfficeWH.entity.ManualSign">
        </set>
        <set name="myNotes">
            <key>
                <column name="CreateUser" length="50" not-null="true">
            </key>
            <one-to-many class="OfficeWH.entity.MyNote">
        </set>
        <set name="loginLogs">
            <key>
                <column name="UserId" length="50" not-null="true">
            </key>
            <one-to-many class="OfficeWH.entity.LoginLog">
        </set>
        <set name="departInfos">
            <key>
                <column name="PrincipalUser" length="50" not-null="true">
            </key>
            <one-to-many class="OfficeWH.entity.DepartInfo">
        </set>
        <set name="messages">
            <key>
                <column name="FromUserId" length="50" not-null="true">
            </key>
            <one-to-many class="OfficeWH.entity.Message">
        </set>
        <set name="operateLogs">
            <key>
                <column name="UserId" length="50" not-null="true">
            </key>
            <one-to-many class="OfficeWH.entity.OperateLog">
        </set>
    </class>

 

RoleInfo表配置:

 

     <bag name="roleRights" table="RoleRight"  ="" order-by="NodeId asc">
            <key column="RoleId">
               
          
            <many-to-many class="OfficeWH.entity.RoleRight" column="NodeId">
        </bag>
        <bag name="userInfos" table="UserRole" inverse="true">
            <key column="RoleId">
               
          
            <many-to-many class="OfficeWH.entity.UserInfo">
        </bag>

 

RoleRight表配置:

 

  <many-to-one name="sysFun" class="OfficeWH.entity.SysFun" fetch="select">
            <column name="NodeId" length="50" not-null="true">
        </many-to-one>
        <many-to-one name="roleInfo" class="OfficeWH.entity.RoleInfo" fetch="select">
            <column name="RoleId" not-null="true">
        </many-to-one>

 

SysFun表配置:

 

  <set name="roleRights">
            <key>
                <column name="NodeId" length="50">
            </key>
            <many-to-many class="OfficeWH.entity.RoleRight" column="RoleId">
        </set>

 

  • 写回答

1条回答

  • iteye_5200 2008-12-13 17:39
    关注

    我没有仔细看你得配置文件,但是从这个异常
    [code="java"]ObjectNotFoundException OfficeWH.entity.RoleRight#101[/code]
    推断,应该是RoleRight表中不存在主键101数据造成的,hibernate的根据主键查询load时如果找不多记录就会报这个异常。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料