ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Torsten Michelmann" <torsten.michelm...@gmx.de>
Subject Re: RE: Data not commited to DB2
Date Wed, 21 Jun 2006 06:46:01 GMT
Hi Christian,

you are right that the line should be in the try-catch. This is just a leftover from my various
debugging attempts. This is also true for the commented endTransaction() call.

Talking about the configuration problem:
Do you have an idea what kind of iBatis configuration parameter I could be missing?
Because if I do the same thing with pure JDBC it is working.

Thank you for your comments.


-------- Original-Nachricht --------
Datum: Tue, 20 Jun 2006 14:19:20 -0400
Von: Poitras Christian <Christian.Poitras@ircm.qc.ca>
An: user-java@ibatis.apache.org
Betreff: RE: Data not commited to DB2

> I believe that your code line
>   Integer
> moKey2=(Integer)myConnection.insert("createCustomerOrderBase_MenuOrder",cok);
> 	    log.debug("createCustomerOrderBase_MenuOrder: created entry with id
> "+moKey2);
> should be in the try catch block with other inserts.
> If the other inserts does not work, then you might have the problem your
> are talking about.
> 
> Also take note that code line
> myConnection.endTransaction();
> must not be commented.
> 
> Hope that helps.
> Christian
> 
> -----Original Message-----
> From: Torsten Michelmann [mailto:torsten.michelmann@gmx.de] 
> Sent: Tuesday, 20 June 2006 10:15
> To: user-java@ibatis.apache.org
> Subject: Data not commited to DB2
> 
> Hi,
> 
> I have a problem with insert statements on DB2 8.1 using the current
> iBatis release.
> The problem is that they are executed without error but when I query the
> DB I don't see any of the entries.
> 
> I strongly assume that it is a configuration problem, but I have spend a
> couple of hours staring at the configuration and cross-checking with the DTD
> without success.
> 
> What is particulary irritating to me is the fact that the call outside the
> transaction was persisted ONCE to the database, all further calls to the
> method did not yield any change on the table.
> The auto generated keys are incremented and iBatis returns the generated
> id's (proven by the debug statements inside my DAO code) but I just can't
> find them on the table.
> 
> Your help is highly appreciated.
> 
> ***my personal DAO***
> public class MomDAO extends BaseDAO {
> 	Logger log=Logger.getLogger(MomDAO.class);
>     public SqlMapClient getSqlMapClient() {
>         SQLMapConfigMOM t = new SQLMapConfigMOM();
>         return t.getSqlMapInstance();
>     }
> 
>     public CustomerOrder createCustomerOrder(final CustomerOrderKey cok)
> throws SQLException {
>         SqlMapClient myConnection=getSqlMapClient();
>         Integer
> moKey2=(Integer)myConnection.insert("createCustomerOrderBase_MenuOrder",cok);
> 	    log.debug("createCustomerOrderBase_MenuOrder: created entry with id
> "+moKey2);
>         try {
>             myConnection.startTransaction();
> 		    //Step 1.1
> 	            Integer
> moKey=(Integer)myConnection.insert("createCustomerOrderBase_MenuOrder",cok);
> 		    log.debug("createCustomerOrderBase_MenuOrder: created entry with id
> "+moKey);
> 		    int newKey=moKey.intValue();
> 		    //Step 2
> 		    Object
> custOrderId=myConnection.insert("createCustomerOrderBase_CustomerOrder",cok);
> 		    log.debug("createCustomerOrderBase_CustomerOrder: created entry with
> id "+(Integer)custOrderId);
> 	    myConnection.commitTransaction();
>         }
>         finally  
>         {
> //            myConnection.endTransaction();
>         }
> 	    
> 	    CustomerOrder co=new CustomerOrder();
> 	    //TODO: load and return complete Customer Order
>         return co;
>     }
> }
> 
> 
> ***SQLMapConfig.xml***
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE sqlMapConfig     
> PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"      
> "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
> <!-- Always ensure to use the correct XML header as above! -->
> <sqlMapConfig>
> 	<settings 
> 		cacheModelsEnabled="false" 
> 		enhancementEnabled="true" 
> 		errorTracingEnabled="true"
> 		lazyLoadingEnabled="true" 
> 		maxRequests="32"
> 		maxSessions="10" 
> 		maxTransactions="5" 
> 		useStatementNamespaces="false" 
> 		/>
> 	<transactionManager type="JDBC" commitRequired="true">
> 
> 		<dataSource type="SIMPLE">
> 			<property name="JDBC.Driver" value="${driver}" />
> 			<property name="JDBC.ConnectionURL" value="${url}" />
> 			<property name="JDBC.Username" value="${username}" />
> 			<property name="JDBC.Password" value="${password}" />
> 		</dataSource>
> 	<sqlMap resource="SqlMap.xml" />
> </sqlMapConfig>
> 
> 
> ***sqlMap.xml***
> <?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="myNamespace">
> 	<insert id="createCustomerOrderBase_MenuOrder"
> parameterClass="CustomerOrderKey">
> 		<![CDATA[
> 			INSERT INTO MENU.MENUORDER 
> 			( SEGMENT, SAISON, MODULE_ID,IS_MOM,VERSION) 
> 			VALUES (#collectionKey.segmentId#, #collectionKey.seasonId#,
> #moduleKey.moduleId#,0,1);
> 		]]>
> 		<selectKey keyProperty="objectId" resultClass="java.lang.Integer" >
> 			<include refid="getGeneratedKey"/>
> 		</selectKey>
> 	</insert>
> 	<insert id="createCustomerOrderBase_CustomerOrder"
> parameterClass="CustomerOrderKey">
> 		<![CDATA[
> 			INSERT INTO MENU.CUSTOMERORDER
> 			( MENUORDER_ID, CUSTOMER_ID, ORDERID) 
> 			VALUES (#objectId#, #customerId#, #orderId#);			
> 		]]>
> 		<selectKey keyProperty="objectId" resultClass="java.lang.Integer" >
> 			<include refid="getGeneratedKey"/>
> 		</selectKey>
> 	</insert>	
> 	
> </sqlMap>
> 
> 
> 
> 
> --
> Greetings
> Torsten
> 
> Echte DSL-Flatrate dauerhaft für 0,- Euro*!
> "Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl

-- 
Gruß
Torsten Michelmann

Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

Mime
View raw message