框架子查询问题.急

leafsoar 2010-02-25 07:18:17

<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框架中怎么配置外键的.看了很多例子,都没有找到原因.

如果还需要什么信息请留言.在线等解决.....
...全文
138 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
leafsoar 2010-02-25
  • 打赏
  • 举报
回复


insert into sys_user (
user_name,
user_password,
user_flag,
user_role_id
) values (
#userName#,
#userPassword#,
#userFlag#,
#userRole##roleId# //这里想表达的是userRole是个对象.怎么取出里面的字段roleID,这样使错的,正确的应该怎么写
)
xiaoguan_Java 2010-02-25
  • 打赏
  • 举报
回复
ding ding ./............
内容概要:SSD2828QN4是一款MIPI主桥接芯片,用于连接应用处理器与传统并行LCD接口及支持MIPI从属接口的LCD驱动器。该芯片支持最高每通道1Gbps的串行链路速度,最多可配置4个数据通道,显著减少了信号数量。它支持多种接口模式,包括RGB+SPI组合接口,适用于驱动智能或非智能显示面板,并能通过命令模式和视频模式传输数据。芯片内置时钟和复位模块、外部接口、协议控制单元(PCU)、包处理单元(PPU)、错误校正码/循环冗余校验(ECC/CRC)模块、长包和命令缓冲区、D-PHY控制器、模拟收发器以及内部锁相环(PLL),确保了高效的数据传输和系统稳定性。此外,文档详细描述了芯片的引脚分配、寄存器设置、操作模式、电源序列、时序特性等关键参数,为开发者提供了全面的技术指导。 适合人群:具备一定硬件设计基础,从事嵌入式系统开发、显示技术研究的研发人员。 使用场景及目标:①实现应用处理器与MIPI兼容显示屏之间的高速数据传输;②优化显示系统的功耗表现,减少电磁干扰(EMI);③通过灵活配置不同接口模式来适应各种显示设备的需求。 阅读建议:此文档面向具有一定电子工程背景的专业人士,建议读者结合实际项目需求深入理解各章节内容,特别是关于寄存器配置、时序要求等方面的具体说明。对于初次接触此类技术的开发者而言,建议先熟悉基本概念再逐步掌握高级功能的应用方法。

81,111

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧