Rollback transactions in CAF
Hi,
If we execute a method from a webservice developed in CAF. The transaction get commited and the data gets stored in the Business objects.
Is there any way to rollback the transactions, Suppose if the UI faces some error then can we revert back the data or delete the business objects created in CAF.
Do v have any functionality inbuild in NWDS CE 7.1 or v manually write some Business Logic to delete these Business objects
Hi,
Web Services are stateless and atomic:
Stateless: no state is kept at service provider (u2018Backendu2019) between service calls
Atomic: each service updating the database does its own commit. If service fails there is no possibility to rollback.
What you can do:
1. First, Create a check service for each modifying service and call it before the service so that the possibility of success of the service will be high.
2. Write a compensation service for each modifying service(E.g Create Flight; Cancel Flight) and call it based on the respoce of the servie.
Refer this document
[ doc1|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00caf8bd-487a-2a10-36a9-93d840309310]
[Doc2|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1078e3b0-ec5d-2a10-f08a-c9b878917b19]
[Doc3|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1078e3b0-ec5d-2a10-f08a-c9b878917b19]
thanks
Similar Messages
-
Hi All
I have parent and child entity services in CAF. Now I want to first create parent ,generate some ids and then save child with reference to the parent Id. Now if I have some problem in saving child then I want complete rollback , I mean I want both parent as well as child dont get saved at all. How can I do that? Can any one of you give me some good doc on transaction management in CAF ?
SunitAs Samir suggested, use Application Service to create your business method. Make sure when you create the method, set the Transaction Type to "Mandatory" to make the method fully transaction inclusive.
Thanx,
Mahesh -
How to use commit and rollback transaction if my i am using MS Access as a
as per my knowledge the transactions commit and rollback is not work if my data base is MS Access then plz give me the logic how i used these transaction with MS Access.
waiting for response
plz mail ur respose if possible at [email protected]Same as every other relational database you can connect to with JDBC.
try
connection.setAutoCommit(false);
// Perform your unit of work here
connection.commit();
catch (SQLException e)
connection.rollback();
e.printStackTrace();
finally
try { if (connection != null) connection.close(); } catch (SQLException ignore) {}
}% -
Problem in executing update after rollback transaction
Hi all
I am using type4 driver oracle9i ,Stateless session Beans CMP. Problem is: after doing rollback i am trying to execute an update query on same id which was rolled back.System is not able to do the same.
Manmeetgot the solution.
cannot rollback and do update in a transaction. -
HOW to rollback transaction?
expert:
two transaction is CALL TRANSACTION tcode1 and CALL TRANSACTION tcode2 perform in turn.
if Call transaction tcode2 occurs error ,CALL TRANSACTION tcode1 will be rollback.how to do it.
thanks in advance.
fgq.Hello There.
I suppose you will have to use, (SAY)
loop at _____
If ____ sucess.
COMMIT WORK.
else.
ROLLBACK WORK.
endif.
endloop.
COMMIT WORK statement updates the database.
If there is no COMMIT WORK, the transaction is terminated in case of error ROLLBACK WORK serves the purpose.
If that solves its fine and if not give feedback.
Good Luck & Regards.
Harsh Dave -
RollBack Transaction using UDO
Hi
I want to perform some validation on MY UDO form. But problem is if i entered some wrong value into our form then what happen, it shows the alert and saved data also. <b>Is it possible to stop this transaction</b> , if yes how???. Plz suggestHi Pankaj,
Not sure what you mean exactly. If you say it shows the alert, do you have a message that shows when you click the add/update button. If so, you can simply avoid SBO from processing the transaction by setting the BubbleEvent variable to false. This variable is passed in with your item event.
Hope it helps,
Adele -
BC4J commit/rollback transaction
I'm using the following code (copied from the complete UIX BC4J application) to delete a row:
<event name="removeCaractGrupo">
<bc4j:findRootAppModule name="GruposMineriosAppModule">
<bc4j:findViewObject name="ClasseAtualCaractGrupoMinerioView">
<bc4j:findRowByKey>
<bc4j:keyBinding>
<bc4j:selectionKey name="caractGruposData" key="keyCaractGrupo" />
</bc4j:keyBinding>
<bc4j:handlers>
<bc4j:removeRow />
<bc4j:executeQuery/>
</bc4j:handlers>
</bc4j:findRowByKey>
</bc4j:findViewObject>
<bc4j:commit/>
</bc4j:findRootAppModule>
</event>
It works fine but if the row cannot be removed because of a constraint violation the row is still removed from the viewObjectScope and appears again only if I send a <bc4j:rollback/> command.
The question is: is there any approach like a try/catch within the uiXML event handler??
<ui:try>
<contents>
<bc4j:commit/>
</contents>
<ui:catch>
<bc4j:rollback/>
</ui:catch>
</ui:try>
Or do I have to call a Java class method to do this??There's nothing like <try>/<catch> in the event handler section. It looks like you'd need to replace the commit handler here with handcoded Java that will rollback in case the commit fails.
-
Hi
I posted in the wrong forum before and I repost it here.
I have a method in session bean method to create 3 records in Table A through another session bean and 1 record in Table B through an entity bean. The methods are declared "Require", but it doesn't rollback when it fails and fall out from exception. I thought the container will take care of it for me, do I need to call setRollbackOnly through SessionContext? Thanks for any info.
Kenny Lau.
-
Hi,
I am working on AR Receipts converison in R12 and trying to create cash receipts using AR_RECEIPT_API_PUB.CREATE_CASH.
As per my data file there are 3 receipts that can be created successfully, but 1 receipt that has a couple of errors.
I dont want even a single receipt to be created in case any record in my data file fails.
I am passing the value fnd_api.g_false to the parameter p_commit. Still this doesn't help me to achieve what i require.
3 Receipts are automatically created, without issuing an external commit and 1 record/receipt failed with error.
Could you please help me with a solution on how to achieve this??? Appreciate your help.
Thanks in advance.
Regards,
KesavaHi,
I myself have figured out the problem.
I have digged in to the API Code and have found that FND_API.G_FALSE is case sensitive. I was passing it in lowercase earlier due to which the problem has arised.
It heps if we pass the value FND_API.G_FALSE in uppercase (or) even if we ignore that value it is fine as it is defaulting to the same.
Thanks,
Kesava Chunduri -
EJB Entity transaction rollback problem
Hello,
I have created 2 beans one is a Stateless Session and the other a Bean Managed Entity Bean. The SS Bean has methods to retrieve an Oracle Connection from a DataSource defined connection pool, and to close a connection. The entity bean I have created is responsible for insterting a new record into one of the tables in my database.
I have a client app that calls the ejbCreate method on the entity bean at which point the Entity EJB takes control, gets a valid connection from the SS EJB, runs a simple working SQL SELECT statement (obtaining correct values), and then attempts to perform an insert into a table using a prepared statement. My problem is that the application runs fine without any errors and all calls are made and all calls seem to be working fine. I have checked to make sure that the Datasource I am using is AutoCommit= false and it is and there are no exceptions being thrown in my EJB's but yet it appears as though the SQL statements executeUpdate() command is not being committed as their is no rows created in the database. Does anyone know what I may be doing wrong. I have all ACL parameters set up correctly and as I stated before the entire app runs without errors and I do have a SELECT statment that is working properly within the same method as the INSERT statement which is not!!! Please send any suggestions!!
Justin
I am using CMT, it is activated by default on Entity Beans I believe. The bean itself is marked as TX_REQUIRED so I believe all the methods automatically are all TX_REQUIRED.
Here is my Bean ejbCreate Method, My PK class, and my ejb-jar.xml file-- I've pasted them below for convenience.
ejbCreate:
public CustomerPK ejbCreate(String aUserName, String aPassword, String aFirstName,
String aMiddleInit, String aLastName, String aEmailAddr)
throws javax.ejb.CreateException {
Connection conn=null;
long nextPrsnID;
long nextCustID;
if (verifyParams(aUserName, aPassword, aFirstName, aMiddleInit,
aLastName, aEmailAddr)) {
if (isUniqueUserName(aUserName)) {
try {
conn=getConnection();
conn.setAutoCommit(false);
nextPrsnID=addPerson(conn,aFirstName,aMiddleInit,aLastName); // adds a person to the person table consists of just simple SQL
nextCustID=addCustomer(conn,nextPrsnID, aUserName,aPassword, aEmailAddr); //adds a customer to the customer table
// SET THE BEAN MANAGED PUBLIC VARIABLES
this.userName=aUserName;
this.password=aPassword;
this.firstName=aFirstName;
this.middleInit=aMiddleInit;
this.lastName=aLastName;
this.emailAddr=aEmailAddr;
this.personID=nextPrsnID;
this.custID=nextCustID;
conn.commit(); // with this statement here the transaction goes through otherwise the DB will not be updated
catch (Exception e){
throw new javax.ejb.CreateException("Experiencing Database Problems-- Unrecoverable Error"); // rollback transaction
finally{
cleanup(conn,null); // close the connection
else { // UserName already exists
throw new javax.ejb.CreateException("Sorry username already exists please choose another one");
else { // Registration parameters were not verifiable
throw new javax.ejb.CreateException("Registration paramater rules were violated");
CustomerPK custPK=new CustomerPK(nextCustID);
return custPK;
EJB CUSTOMER PRIMARY KEY CLASS:
public class CustomerPK implements java.io.Serializable {
// PRIMARY KEY VARIABLES
public long CustomerID;
public CustomerPK(long aCustomerID) {
this.CustomerID=aCustomerID;
public CustomerPK() {
public String toString(){
return ((new Long(CustomerID)).toString());
public boolean equals(Object aComparePK){
if (this.CustomerID==((CustomerPK)aComparePK).CustomerID){
return true;
return false;
public int hashCode(){
return ((new Long(CustomerID).toString()).hashCode());
} // END-CLASS
CUSTOMER ejb-jar.xml
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>Customer</ejb-name>
<home>CustomerHome</home>
<remote>Customer</remote>
<ejb-class>CustomerBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>CustomerPK</prim-key-class>
<reentrant>False</reentrant>
<resource-ref>
<res-ref-name>jdbc/DeveloperPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Customer</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
"Cameron Purdy" <[email protected]> wrote:
>Are you using CMT? Have you marked the methods as REQUIRED?
>
>Peace,
>
>--
>Cameron Purdy
>Tangosol, Inc.
>http://www.tangosol.com
>+1.617.623.5782
>WebLogic Consulting Available
>
>
>"Justin Jose" <[email protected]> wrote in message
>news:[email protected]...
>>
>> Hello,
>>
>> I have created 2 beans one is a Stateless Session and the other a Bean
>Managed Entity Bean. The SS Bean has methods to retrieve an Oracle
>Connection from a DataSource defined connection pool, and to close a
>connection. The entity bean I have created is responsible for insterting a
>new record into one of the tables in my database.
>> I have a client app that calls the ejbCreate method on the entity bean at
>which point the Entity EJB takes control, gets a valid connection from the
>SS EJB, runs a simple working SQL SELECT statement (obtaining correct
>values), and then attempts to perform an insert into a table using a
>prepared statement. My problem is that the application runs fine without
>any errors and all calls are made and all calls seem to be working fine. I
>have checked to make sure that the Datasource I am using is AutoCommit=
>false and it is and there are no exceptions being thrown in my EJB's but yet
>it appears as though the SQL statements executeUpdate() command is not being
>committed as their is no rows created in the database. Does anyone know
>what I may be doing wrong. I have all ACL parameters set up correctly and
>as I stated before the entire app runs without errors and I do have a SELECT
>statment that is working properly within the same method as the INSERT
>statement which is not!!! Please send any suggestions!!
>>
>> Justin
>
>
-
Can we rollback the update query using Transaction?
Can we rollback the Update query by writing the update query with in the transaction, as i am implementing different update queries, sometimes I am mistakenly updating the table without where criteria, which is messing up the table. Is there anyway where
we can write the update query within a transaction and rollback that particular update query which I am writing. I do have a backup table, but that wont be useful because we are doing lot of updates in a span of minutes. I researches about Apex Sql logs too,
but we do not have access to download such tools. So, can anyone give me a good solution for this?Sure, if you use transaction like this
begin transaction
update 1
update 2
rollback transaction
both updates will be rollbacked.
If you want to always be sure about rows you're about to change, always first try with SELECT statement and put each individual UPDATE into separate transaction with rollback at the end, e.g.
begin transaction
select ... where some condition
update . where same condition
select ... where same condition to verify update
rollback transaction
If your last select showed correct info, change ROLLBACK into COMMIT and re-run that script again to perform the actual update.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
RuntimeException - Transaction Rollback
Hi,
I am using weblogic 6.1 on WINDOWS platform..
hv few questions on Container Managed Transactions:
1. What is the Bean-default transaction attribute
(If I don't specify any transaction attribute for
one of the method in SLSB).
2. Does Weblogic container rollbacks transaction for any
RuntimeException that has been thrown from Business
method OR only for EJBException.
3. What are the pros and cons of Specifying a Transaction
attribute for a Business method that only executes
SELECT statements.
4. if I want to manage my trasaction explicitly using
USerTransaction (Client Demarcated) do I hv control
over Distributed transactions.
thx,
Ramesh
Ramesh <[email protected]> wrote:
> Hi,
> I am using weblogic 6.1 on WINDOWS platform..
> hv few questions on Container Managed Transactions:
> 1. What is the Bean-default transaction attribute
> (If I don't specify any transaction attribute for
> one of the method in SLSB).
I think the default is 'Supports'
> 2. Does Weblogic container rollbacks transaction for any
> RuntimeException that has been thrown from Business
> method OR only for EJBException.
Yes. There is a table in the 'Exception Handing' section of the EJB
spec which describes what happens when bean methods throw various
exceptions.
> 3. What are the pros and cons of Specifying a Transaction
> attribute for a Business method that only executes
> SELECT statements.
At the very least it wil decrease number of ejbLoad()'s if you
use Entity Beans.
> 4. if I want to manage my trasaction explicitly using
> USerTransaction (Client Demarcated) do I hv control
> over Distributed transactions.
> thx,
> Ramesh
Dimitri
-
TRANSACTION을 ROLLBACK SEGMENT에 할당하는 방법(SET TRANSACTION USE)
제품 : ORACLE SERVER
작성날짜 : 2003-04-04
TRANSACTION을 ROLLBACK SEGMENT에 할당하는 방법
==============================================
(SET TRANSACTION USE ROLLBACK SEGMENT)
Purpose
Batch job 등을 사용할 때 특별히 크게 만든 rollback segment를 사용하도록
할 수가 있다. transaction에 특정한 rbs를 지정하는 방법을 알아보자.
Explanation
Oracle은 다음과 같은 규칙에 의해 각 Transaction이 사용하는 Rollback
segment를 결정한다.
1. Active Transaction의 수가 가장 작은 Rollback Segment에 할당한다.
2. 만약 1의 조건에 만족하는 Rollback segment가 하나 이상이면, 가장
마지막에 할당된 rbs 다음의 rbs를 할당한다. 이것은 undo 기능을 더
오래 지속시키도록 해 준다.
그러나, Application이 큰 rollback segment가 필요하다면 위와 같이
자동적인 rollback segment의 할당이 아닌 Manual하게 특정 rollback
segment를 할당 가능하다.
다음의 방법을 사용한다.
1) 큰 rollback segment를 만든다. 큰 rollback segment 를 만들기
위해서는 rbs tablespace에 영역이 충분히 커야 하므로 필요할 경우
tablespace를 확장하는 작업을 한다.
<tablespace 확장>
$ sqlplus system/manager
sql> alter tablespace rbs add datafile '?/rbs1SID.dbf' size 100m;
<rollback segment 생성>
sql> create rollback segment big_rbs storage(initial 10m next 10m)
tablespace rbs;
sql> alter rollback segment big_rbs online;
2) Transaction 를 assign 한다.
<sqlplus>
SQL> set transaction use rollback segment big_rbs;
<pro*c>
exec sql commit work;
exec sql set transaction use rollback segment big_rbs;
<forms>
dbms_transaction.use_rollback_segment('big_rbs');
이와 같이 지정하면 이후에 commit 또는 rollback이 일어날 때까지
한 transaction에만 해당된다. -
Statspack Rollback per transaction % vs Log Miner rollback = 1
Hi,
I'm investigating high Rollback per transaction % = 30% in our 9.2.0.8 EE databse .
First think was checking all archive logs from period equal to statspack snapshot range
but looks like there is huge discrepancy between that two tools .
What I've found from v$logmnr_contents where rollback = 1 was that
only 0,5% transactions was rollbacked .
I'm wondering what could cause such difference is that true
unique constraint violation (or other exceptions) is not recorded in redologs as rollbacked transaction ?
Any ideas ?
Major problem is still what is causing high rollback % .
Regards
GI'm investigating increase in undo usage and Rollback per transaction % = 30 .
Strange issue because v$transacion is not showing demanding transacions , rather small quick (oltp system).
Here is sp report:
DB Name DB Id Instance Inst Num Release Cluster Host
XXXX 1497360911 XXXXX 1 9.2.0.8.0 NO XXXXX
Snap Id Snap Time Sessions Curs/Sess Comment
Begin Snap: 89346 23-Sep-09 08:00:02 638 13.0
End Snap: 89365 23-Sep-09 20:00:05 710 19.1
Elapsed: 720.05 (mins)
Cache Sizes (end)
~~~~~~~~~~~~~~~~~
Buffer Cache: 3,072M Std Block Size: 8K
Shared Pool Size: 2,048M Log Buffer: 2,000K
Load Profile
~~~~~~~~~~~~ Per Second Per Transaction
Redo size: 344,858.21 6,796.87
Logical reads: 131,932.52 2,600.28
Block changes: 2,211.70 43.59
Physical reads: 7,457.34 146.98
Physical writes: 236.52 4.66
User calls: 6,197.31 122.14
Parses: 2,236.26 44.07
Hard parses: 20.63 0.41
Sorts: 330.72 6.52
Logons: 0.34 0.01
Executes: 3,097.97 61.06
Transactions: 50.74
% Blocks changed per Read: 1.68 Recursive Call %: 35.95
Rollback per transaction %: 30.58 Rows per Sort: 31.38
Instance Efficiency Percentages (Target 100%)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Buffer Nowait %: 99.97 Redo NoWait %: 100.00
Buffer Hit %: 94.37 In-memory Sort %: 100.00
Library Hit %: 99.63 Soft Parse %: 99.08
Execute to Parse %: 27.82 Latch Hit %: 99.83
Parse CPU to Parse Elapsd %: 30.18 % Non-Parse CPU: 95.65
Shared Pool Statistics Begin End
Memory Usage %: 100.00 100.00
% SQL with executions>1: 38.24 35.74
% Memory for SQL w/exec>1: 76.94 86.29
Top 5 Timed Events
~~~~~~~~~~~~~~~~~~ % Total
Event Waits Time (s) Ela Time
CPU time 109,020 32.54
db file sequential read 40,144,341 96,883 28.91
db file scattered read 26,524,497 66,948 19.98
sbtwrite2 4,141,351 23,994 7.16
SQL*Net message from dblink 33,497,630 17,097 5.10
------------------------------------------------------------- -
According to
MSDN SqlTransaction.Rollback() method must throw InvalidOperationException in case the transaction has already been committed or rolled back.
However, in my tests I don't get any exceptions. Here is the code:
CREATE PROCEDURE dbo.USP_TEST_TX_PROC
AS
BEGIN
SELECT 1/0;
ROLLBACK TRANSACTION;
END
GO
using(SqlConnection con = new SqlConnection(@"Data Source=XXX;Initial Catalog=TestDB;Integrated Security=True"))
con.Open();
SqlTransaction tr = con.BeginTransaction();
SqlCommand cmd = new SqlCommand("dbo.USP_TEST_TX_PROC", con, tr) { CommandType = CommandType.StoredProcedure};
try
cmd.ExecuteNonQuery();
tr.Commit();
catch (Exception ex)
try
tr.Rollback();
catch (Exception ex2)
Console.WriteLine(" Message: {0}", ex2.Message);
What am I doing wrong?
Thank you.
AlexeyHello Alexey,
I created a client side demo which could throw the InvalidOperationException:
using (SqlConnection connection = new SqlConnection(@"Server=(localdb)\Projects;Database=DFDB;Trusted_Connection=True;"))
connection.Open();
SqlCommand command = connection.CreateCommand();
SqlTransaction transaction;
transaction = connection.BeginTransaction("SampleTransaction");
command.Connection = connection;
command.Transaction = transaction;
try
command.CommandText = "ProInsertIntoOrder 1,'1'";
command.ExecuteNonQuery();
transaction.Rollback();
throw new Exception();
catch (Exception ex)
// Attempt to roll back the transaction.
try
transaction.Rollback();
catch (InvalidOperationException ex2)
Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType());
Console.WriteLine(" Message: {0}", ex2.Message);
You could have a try. However, it is not clear why it could detect the ROLLBACK statement on the server side, I suggest that you could post this feedback to:
https://connect.microsoft.com/VisualStudio/feedback/LoadSubmitFeedbackForm
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Maybe you are looking for
-
"French Script" Font . How do I get it on my new MacBook?
I have just bought a new MacBook and had my data transferred from my old MAC where I had many folders in the French Script font. (These were older folders on OS9). These were transferred in another font. Before I purchase this font I want to make sur
-
How to install the sms and phonebook
how can I install the sms and phonebook
-
Mavericks upgrade made CS5 VERY wonky!
Encore CS5 freezes/crashes whenever I try to switch the build format to Blu-ray (from DVD- I own a LaCie Blu-ray burner). This worked just fine with Mountain Lion 10.8.5. Any suggestions? I wish I had never upgraded my Mac OS. CS5 had numerous proble
-
hy there, i wondering is there any chance to record tv programs while n95 connected via tv cable ? Nokia N95 v.20.0.15 + 2 Gb microS + RotateMe beta7 + Nokmote beta1+ ShutUp beta1
-
Subscriber Manager Integration with Radius.
I will install SCE in entrpise network but i have 6 Raduis servers. but i do not know how many radius servers can i intergrate with sucscriber manager?.