看书练习的时候使用selectOne总是返回null,不知道什么原因,大神们看看。这是怎么回事儿?
JAVA代码
VisitingModel visitingModel = (VisitingModel)sessionTemplate.selectOne("com.lag.lingzhi.visiting.dao.VisitingDao.getVisitingList",1);
sql语句
<select id="getVisitingList" resultType="com.lag.lingzhi.visiting.model.VisitingModel" parameterType="int">
SELECT * FROM VISITING_MODEL_TABLE VMT WHERE VMT.V_ID = #{vId}
</select>
日志显示sql已执行
2014-05-11 16:37:51,044 DEBUG [http-8080-3] (DataSourceUtils.java:110) - Fetching JDBC Connection from DataSource
2014-05-11 16:37:51,515 DEBUG [http-8080-3] (JakartaCommonsLoggingImpl.java:27) - Creating SqlSession with JDBC Connection [jdbc:mysql://localhost:3306/lingzhi, UserName=root@localhost, MySQL-AB JDBC Driver]
2014-05-11 16:37:51,520 DEBUG [http-8080-3] (JakartaCommonsLoggingImpl.java:27) - ooo Connection Opened
2014-05-11 16:37:51,527 DEBUG [http-8080-3] (JakartaCommonsLoggingImpl.java:27) - JDBC Connection [jdbc:mysql://localhost:3306/lingzhi, UserName=root@localhost, MySQL-AB JDBC Driver] will not be managed by Spring
2014-05-11 16:37:51,537 DEBUG [http-8080-3] (JakartaCommonsLoggingImpl.java:27) - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@10a234] was not registered for synchronization because synchronization is not active
2014-05-11 16:37:51,742 DEBUG [http-8080-3] (JakartaCommonsLoggingImpl.java:27) - ==> Executing: SELECT * FROM VISITING_MODEL_TABLE VMT WHERE VMT.V_ID = ?
2014-05-11 16:37:51,742 DEBUG [http-8080-3] (JakartaCommonsLoggingImpl.java:27) - ==> Parameters: 1(Integer)
2014-05-11 16:37:51,771 DEBUG [http-8080-3] (JakartaCommonsLoggingImpl.java:27) - <== Columns: v_id, v_area, v_agency, v_intoDate, v_outDate, v_personNum, v_adviser, v_customer, v_sex, v_phoneNum, v_customerArea, v_askType, v_frequency, v_customerFrom, v_messageFrom, v_likeType, v_compareCar, v_likeLevel, v_introduceType, v_askPrice, v_tryDriver, v_saveMessage, v_sendfor, v_buyCar, v_remarks
2014-05-11 16:37:51,779 DEBUG [http-8080-3] (JakartaCommonsLoggingImpl.java:27) - <== Row: 1, 2, 3, 2014-05-10 00:00:00.0, 2014-05-10 00:00:00.0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25
2014-05-11 16:37:51,786 DEBUG [http-8080-3] (DataSourceUtils.java:332) - Returning JDBC Connection to DataSource
还想看什么了的,说出来我再贴上。
------解决方案--------------------
V_ID=1的记录存在不
------解决方案--------------------
那说明你的传参有问题了