<sqlMap namespace="sysRole">
  <typeAlias alias="sysRole" type="com.klt.entity.SysRole"/>  <resultMap id="SysRoles" class="sysRole">
    <result property="roleId" column="role_id"/>
    <result property="roleName" column="role_name"/>
    <result property="roleDesc" column="role_desc"/>
    <result property="roleFlag" column="role_flag"/>
    
  </resultMap>  <!-- Select with no parameters using the result map for Account class. -->
  <select id="getAllSysRole" resultClass="SysRole" resultMap="SysRoles">
    select * from sys_role
  </select>
  <select id="getSysRole" resultClass="SysRole" resultMap="SysRoles"  parameterClass="int" >
    select * from sys_role where role_id =#value#
  </select></sqlMap>
<sqlMap namespace="sysRoleRight">
<typeAlias alias="sysRoleRight" type="com.klt.entity.SysRoleRight" /> <resultMap id="SysRoleRights" class="sysRoleRight">
<result property="rfId" column="rf_id" />
<result property="rfRole" select="sysRole.getSysRole" column="rf_role_id" />
</resultMap> <!-- Select with no parameters using the result map for Account class. -->
<select id="getAllSysRoleRight" resultClass="SysRoleRight"
resultMap="SysRoleRights">
select * from sys_role_right
</select>
<select id="getSysRoleRight" resultClass="SysRoleRight"
parameterClass="int" resultMap="SysRoleRights">
select * from sys_role_right where rf_id=#value#
</select></sqlMap>
ApplicationContext cxt = new FileSystemXmlApplicationContext("classpath:applicationContext.xml");
SysRoleRightDAO sy = (SysRoleRightDAO)cxt.getBean("sysRoleRightDAO");
SysRoleRight rr = sy.getSysRoleRightByRfId(399);
System.out.println(rr.getRfId());  这样写报错.
如果把下面那个xml文件中
"<result property="rfRole" select="sysRole.getSysRole" column="rf_role_id" />"
删去的话.就没有问题.也就是说外键问题.在ibatis框架中怎么写外键对象的赋值配置.
单独调用第一个xml中的"getSysRole"也没有问题.
错误信息如下.
log4j:WARN No appenders could be found for logger (org.springframework.context.support.FileSystemXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];   
--- The error occurred in com/klt/entity/map/SysRoleRight.xml.  
--- The error occurred while applying a result map.  
--- Check the sysRoleRight.SysRoleRights.  
--- Check the result mapping for the 'rfRole' property.  
--- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no statement named sysRole.getSysRole in this SqlMap.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/klt/entity/map/SysRoleRight.xml.  
--- The error occurred while applying a result map.  
--- Check the sysRoleRight.SysRoleRights.  
--- Check the result mapping for the 'rfRole' property.  
--- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no statement named sysRole.getSysRole in this SqlMap.
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:124)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:322)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:212)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:271)
at com.klt.dao.impl.SysRoleRightDAOImpl.getSysRoleRightByRfId(SysRoleRightDAOImpl.java:19)
at com.klt.test.Test.main(Test.java:18)
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/klt/entity/map/SysRoleRight.xml.  
--- The error occurred while applying a result map.  
--- Check the sysRoleRight.SysRoleRights.  
--- Check the result mapping for the 'rfRole' property.  
--- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no statement named sysRole.getSysRole in this SqlMap.
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:273)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
... 3 more
Caused by: com.ibatis.sqlmap.client.SqlMapException: There is no statement named sysRole.getSysRole in this SqlMap.
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:293)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.getMappedStatement(SqlMapClientImpl.java:202)
at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getNestedSelectMappingValue(BasicResultMap.java:471)
at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResultMap.java:340)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:381)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:301)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:190)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
... 9 more
在ibatis框架中怎么配置外键的.看了很多例子,都没有找到原因.如果还需要什么信息请留言.在线等解决.....