Hi Sam,
Comments in line ...

Sam Su wrote:

> Sorry for my negligence. In fact my code is like following:
>
> /***********************code*******************************/
> List objs=new ArrayList();
> User user1=UserFactory.INSTANCE.createUser();
> user1.setUserId("6");
> user1.setPassword("898989");
> user1.setName("wo");
> user1.setAvailable("1");
>
> User user2=UserFactory.INSTANCE.createUser();
> user2.setUserId("2");
> user2.setPassword("898989");
> user2.setName("wo");
> user2.setAvailable("1");
>
> objs.add(user1);
> objs.add(user2);
>
> Connection conn = dataSource.getConnection();
> conn.setAutoCommit(false);
> DAS das =
> DAS.FACTORY.createDAS(newClassPathResource(schemaConfig).getInputStream(),
>
> conn);
> Command command = das.getCommand(commandName);
> DataObject root = command.executeQuery();
> if (logger.isDebugEnabled()) logger.debug("dataobject collection to
> be insert:" +objects.toString());
> for (int i = 0; i < objects.size(); i++)
> root.getList("User").addAll(objs);
> das.applyChanges(root);
>
>
> /************************************exception
> thrown*************************************************/
> the exception is:
>
> Caused by: java.lang.RuntimeException: java.sql.SQLException: ORA-00001:
> 违反唯一约束条件 (CCP.PK_CCP_USER)
>
> at org.apache.tuscany.das.rdb.impl.InsertCommandImpl.execute(
> InsertCommandImpl.java:47)
> at org.apache.tuscany.das.rdb.impl.ChangeOperation.execute(
> ChangeOperation.java:73)
> at org.apache.tuscany.das.rdb.impl.Changes.execute(Changes.java:57)
> at org.apache.tuscany.das.rdb.impl.ApplyChangesCommandImpl.execute(
> ApplyChangesCommandImpl.java:69)
> at org.apache.tuscany.das.rdb.impl.DASImpl.applyChanges(DASImpl.java:244)
> at com.pccw.odc.framework.integration.dao.sdo.BaseSdoImpl.insert(
> BaseSdoImpl.java:96)
> ... 16 more
> Caused by: java.sql.SQLException: ORA-00001: 违反唯一约束条件
> (CCP.PK_CCP_USER)
>
> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
> at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
> at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
> at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)
> at oracle.jdbc.ttc7.TTC7Protocol.executeFetch(TTC7Protocol.java:1002)
> at
> oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java
> :2155)
> at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java
> :2032)
> at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(
> OracleStatement.java:2894)
> at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(
> OraclePreparedStatement.java:608)
> at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(
> DelegatingPreparedStatement.java:101)
> at org.apache.tuscany.das.rdb.impl.Statement.executeUpdate(Statement.java
> :173)
> at org.apache.tuscany.das.rdb.impl.Statement.executeUpdate(Statement.java
> :133)
> at org.apache.tuscany.das.rdb.impl.InsertCommandImpl.execute(
> InsertCommandImpl.java:44)
> ... 21 more
>
> /**************************************************************/
>
> user2 (who's userId is 2) is fail to be inserted into database caused by
> the primary key conflict, and the user1(who's userId is 6) has been
> inserted
> into database successfully but not rollback.
>
> I does not turn off the das transaction management by
> declaring <ConnectionInfo managedtx="false"/> in configuration file,
> so the
> transaction is controlled by DAS.Furthermore, not only insert operation,
> update/delete has the same problem.
>
> /***************************************************************/
>
> When I trace the source codes of Tuscany DAS, I find DAS will produce
> corresponding commands ( like
> InsertCommandImpl/DeleteCommandImpl/UpdateCommandImpl...) for every
> change
> in ChangeSummary, and DAS will call exceute() method of these commands in
> turn. However, following code snippet is from the exceute() of
> InsertCommandImpl class.
>
> public void execute() {
>
> boolean success = false;
> try {
> statement.executeUpdate(parameters, keys);
> success = true;
> } catch (SQLException e) {
> throw new RuntimeException(e);
> } finally {
> if (success) {
> statement.getConnection().cleanUp();
> } else {
> *statement.getConnection().errorCleanUp(); *
> }
> }
>
> }
>
> and following code snippet is of statement.getConnection().cleanUp():
>
> public void cleanUp() {
> try {
> if (managingTransaction) {
> if (this.logger.isDebugEnabled()) {
> this.logger.debug("Committing Transaction");
> }
> connection.commit();
> }
> } catch (SQLException e) {
> throw new RuntimeException(e);
> }
> }
>
> As from the above codes, that means every command will be exceute in one
> single transaction.
>
All modified SDOs should be flushed to the database in a single transaction.

What should be happening in this case, since there is a duplicate key
error, is that "success" will not be true forcing execution down the
"errorCleanUp" path. This path will perform a rollback on the
connection. Can you verify that this is or is not happening? Thanks!

> I think it may not comply with the SDO specification, am I right?




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to