Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

iBatis - Inserted record not getting committed

 
Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New to iBatis. Using 2.3.3.720 with Spring 2.5.

Even though I have access rights for inserts in that table for using the datasource (user id, password etc.), I do not see the record getting committed.

I can successfully do Select on that table using the same datasource. As such, I know that connection, datasource etc. are good.

Following code for insert gets executed successfully. Also see prepared statement, which looks right. No exception is thrown. But the record does not get committed/inserted.

MyObj.java has 3 attributes namely attr1, attr2, attr3.

MY_TABLE has 3 coulms namely COL1, COL2, COL3 that match with (data type etc.) attr1, attr2 and attr3 respectively.

MyObj.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC
"-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="OffenseCode">
<typeAlias
alias="MyObj"
type="org.poc.domain.MyObj"
/>

<insert id="insertIntoMyObj" parameterClass="MyObj">
insert into MY_TABLE (
COL1,
COL2,
COL3)
values (
#attr1#,
#attr2#,
#attr3#
)
</insert>
</sqlMap>

I call the above insert in the following way from Java main method:

MyObj obj = new MyObj(1, "a", new java.sql.Date()); // int, String, Date are data types for attr1, attr2, attr3
MyObj ret = (MyObj ) iBatisTemplate.insert("insertIntoMyObj", obj);

Following are print-outs in Console:

13:59:49,781 DEBUG SqlMapClientTemplate:177 - Opened SqlMapSession [com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl@404e404e] for iBATIS operation
13:59:49,812 DEBUG Connection:27 - {conn-100000} Connection
13:59:49,843 DEBUG DataSourceUtils:112 - Fetching JDBC Connection from DataSource
13:59:49,843 DEBUG SingleConnectionDataSource:163 - Creating new JDBC DriverManager Connection to [jdbc b2 B2E]
13:59:50,063 INFO SingleConnectionDataSource:244 - Established shared JDBC Connection:
DB2Connection
{
connectionHandle = 1
SPConnected = false
source = DBName
user = myUser
conArgs =
closed = false
describeCached = false
describeParam = true
isReadOnly = false
autoClose = false
LONGDATA compat = false
}

13:59:50,063 DEBUG SqlMapClientTemplate:194 - Obtained JDBC Connection [
DB2Connection
{
connectionHandle = 1
SPConnected = false
source = DBName
user = myUser
conArgs =
closed = false
describeCached = false
describeParam = true
isReadOnly = false
autoClose = false
LONGDATA compat = false
}
] for iBATIS operation
13:59:50,078 DEBUG Connection:27 - {conn-100000} Preparing Statement: insert into MY_TABLE ( COL1, COL2, COL3) values ( ?, ?, ?)
13:59:50,110 DEBUG PreparedStatement:27 - {pstm-100001} Executing Statement: insert into MY_TABLE ( COL1, COL2, COL3) values ( ?, ?, ? )
13:59:50,110 DEBUG PreparedStatement:27 - {pstm-100001} Parameters: [1, a, 2008-08-07]
13:59:50,110 DEBUG PreparedStatement:27 - {pstm-100001} Types: [java.lang.Integer, java.lang.String, java.lang.String, java.sql.Date]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic