Java iBatis缺少关键字
运行iBatis insert命令时收到此错误:Java iBatis缺少关键字,java,oracle11g,ibatis,Java,Oracle11g,Ibatis,运行iBatis insert命令时收到此错误: DEBUG [main] - Returned connection 31746664 to pool. DEBUG [main] - Checked out connection 31746664 from pool. DEBUG [main] - {conn-100014} Connection DEBUG [main] - {conn-100014} Preparing Statement: INSERT INTO POR
DEBUG [main] - Returned connection 31746664 to pool.
DEBUG [main] - Checked out connection 31746664 from pool.
DEBUG [main] - {conn-100014} Connection
DEBUG [main] - {conn-100014} Preparing Statement: INSERT INTO PORTFOLIOS ( theme_id , start_date , portfolio_name , amount , index_cd , model_cd , last_rebalance , months_between_rebalance ) VALUES ( 1 , SYSDATE , ? , ? , ? , ? , SYSDATE , ?) RETURNING portfolio_id
DEBUG [main] - {pstm-100015} Executing Statement: INSERT INTO PORTFOLIOS ( theme_id , start_date , portfolio_name , amount , index_cd , model_cd , last_rebalance , months_between_rebalance ) VALUES ( 1 , SYSDATE , ? , ? , ? , ? , SYSDATE , ?) RETURNING portfolio_id
DEBUG [main] - {pstm-100015} Parameters: [testPortfolio2New, 100000.0, null, null, 0]
DEBUG [main] - {pstm-100015} Types: [java.lang.String, java.lang.Double, null, null, java.lang.Integer]
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in ObjectRelationalMapping.xml.
--- The error occurred while applying a parameter map.
--- Check the sectoranalysis.domain.insertPortfolio-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLSyntaxErrorException: ORA-00925: missing INTO keyword
映射文件中的相关位为:
<insert id="insertPortfolio" parameterClass="com.fimt.sectoranalysis.domain.portfolio.Portfolio">
INSERT INTO PORTFOLIOS
( theme_id
, start_date
, portfolio_name
, amount
, index_cd
, model_cd
, last_rebalance
, months_between_rebalance
)
VALUES
( 1
, SYSDATE
, #name#
, #investment#
, #index.ticker#
, #model.modelId#
, SYSDATE
, #frequency#)
RETURNING portfolio_id
</insert>
插入投资组合
(主题编号
,开始日期
,公文包名称
数量
,索引(光碟)
,型号(光碟)
,最后再平衡
,再平衡之间的月数
)
价值观
( 1
,SYSDATE
,#姓名#
,#投资#
,#index.ticker#
,#model.modelId#
,SYSDATE
,#频率#)
返回投资组合\u id
我不明白,因为INTO关键字很清楚。为什么我的Oracle DB返回此错误?语法是:
INSERT INTO (...) VALUES (...) RETURNING (...) INTO (...)
在您的示例中,Oracle正在抱怨,因为它期望第二个INTO关键字。
我将尝试使用带有resultClass参数的语句:
<statement id="insertPortfolio" parameterClass="com.fimt.sectoranalysis.domain.portfolio.Portfolio" resultClass="int">
...
</statement>
...
有关更多示例,请参见: