浏览 2996 次
|
锁定老贴子 主题:iBatis按参数查询的问题
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2005-07-17
表内容:
[code:1]CREATE TABLE `station` ( `StationID` int(6) unsigned NOT NULL auto_increment, `StationNumber` varchar(50) default NULL, `StationName` varchar(50) default NULL, `StationAddress` varchar(50) default NULL, `StationType` int(4) default NULL, `AssessType` int(4) default NULL, `TransformerCapacity` int(4) default NULL, `LineID` int(4) default NULL, PRIMARY KEY (`StationID`) ) TYPE=MyISAM;[/code:1] ResultMap是这样写的 [code:1] <resultMap id="result" class="dao.ibatis.db.Station"> <result property="stationID" column="StationID" columnIndex="1"/> <result property="stationNumber" column="StationNumber" columnIndex="2"/> <result property="stationName" column="StationName" columnIndex="3"/> <result property="stationAddress" column="StationAddress" columnIndex="4"/> <result property="stationType" column="StationType" columnIndex="5"/> <result property="assessType" column="assessType" columnIndex="6"/> <result property="transformerCapacity" column="TransformerCapacity" columnIndex="7"/> <result property="lineID" column="LineID" columnIndex="8"/> </resultMap> [/code:1] POJO这样 [code:1]package dao.ibatis.db; import java.io.Serializable; public class Station implements Serializable { private int stationID; private String stationNumber; private String stationName; private String stationAddress; private int stationType; private int assessType; private int transformerCapacity; private int lineID; public int getAssessType() { return assessType; } public void setAssessType(int assessType) { this.assessType = assessType; } public int getLineID() { return lineID; } public void setLineID(int lineID) { this.lineID = lineID; } public String getStationAddress() { return stationAddress; } public void setStationAddress(String stationAddress) { this.stationAddress = stationAddress; } public int getStationID() { return stationID; } public void setStationID(int stationID) { this.stationID = stationID; } public String getStationName() { return stationName; } public void setStationName(String stationName) { this.stationName = stationName; } public String getStationNumber() { return stationNumber; } public void setStationNumber(String stationNumber) { this.stationNumber = stationNumber; } public int getStationType() { return stationType; } public void setStationType(int stationType) { this.stationType = stationType; } public int getTransformerCapacity() { return transformerCapacity; } public void setTransformerCapacity(int transformerCapacity) { this.transformerCapacity = transformerCapacity; } } [/code:1] SQL语句这样写的 [code:1]<select id="getStationListByLineID" resultMap="result"> select * from station where `LineID` = #value# </select>[/code:1] 但是会提示检查Station.Result说在set一个property的时候出错了,不知道为什么 这里的LineID是数字型的,我再实际查询中传过来的参数是一个字符串: [code:1] return getSqlMapClientTemplate().queryForList("getStationListByLineID", String.valueOf(LineID)); [/code:1] 请问,问题出在什么地方??我的头很大 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
最后更新时间:2005-07-17
<select id="getStationListByLineID"
resultMap="result" parameterClass="java.lang.Integer"> 要写参数的类型 |
|
| 返回顶楼 | |
|
最后更新时间:2005-07-18
我的参数传过来的时候是字符型的,这样写没关系吗?我去试试看,谢谢:)
|
|
| 返回顶楼 | |
|
最后更新时间:2005-07-18
mysql中的日期时间型如何映射到iBatis??SQLserver的Datetime类型?
|
|
| 返回顶楼 | |
|
最后更新时间:2005-07-18
不知道为什么,在jdk5.0中我指定
<select id="getStationListByLineID" resultMap="result" parameterClass="java.lang.String"> 没有问题 在jdk1.4.2种指定 <select id="getStationListByLineID" resultMap="result" parameterClass="java.lang.String"> 出错,有人知道为什么吗?? |
|
| 返回顶楼 | |




