Transaction cache VS Session cache
Hi,
Some one please help me to understand the concepts of ttransaction cache VS Session cache.
In the user guide its given that
For AM : Any data stored on the transaction is accessible to all pages that share the same root application module instance .
For Session : Session cache only when you need to set and access simple values in many pages, which have different root application modules
(The transaction cache discussed above isn't an option)
Are these 2 different ? if so how ? Why the transaction cache is different from session cache, both are used to store data and both are available across pages assuming all pages share the same AM.
Thank you for all your help.
GustavoJimenez,
Thank for taking time and explaining it.
I understand that, if multiple pages share the same AM and retainAM flag ='N' then it will create multiple instances of same AM. so is the AM cache is common for all the AM instances ?
Can you please explain more about session cache and where it comes into picture ? Is session cache and AM cache has same attributes ?
Similar Messages
-
Coherence 3.6.0 transactional cache and POF - NULL values
Hi,
We are trying to use the new transactional scheme defined in 3.6.0 and we encounter an abnormal behaviour. The code executes without any exception or warnings but in the cache we find the key associated with a NULL value.
To try to identify the problem, we defined two services (see cache-config below):
- one transactional cache
- one distributed cache
If we try to insert into transactional cache primitives or strings everything is normal (both key and value are visible using coherence console). But if we try to insert custom classes using POF, the key is inserted with a NULL value.
In same cluster we defined a distributed cache that uses the same POF classes/configuration. A call to put will succeed in any scenario (both key and value are visible using coherence console).
<?xml version="1.0"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">
<cache-config>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>cnt.*</cache-name>
<scheme-name>storage.transactionalcache.cnt.scheme</scheme-name>
</cache-mapping>
<cache-mapping>
<cache-name>stt.*</cache-name>
<scheme-name>storage.distributedcache.stt.scheme</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<transactional-scheme>
<scheme-name>storage.transactionalcache.cnt.scheme</scheme-name>
<service-name>storage.transactionalcache.cnt</service-name>
<thread-count>10</thread-count>
<serializer>
<class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
<init-params>
<init-param>
<param-type>String</param-type>
<param-value>cnt-pof-config.xml</param-value>
</init-param>
</init-params>
</serializer>
<backing-map-scheme>
<local-scheme>
<high-units>250M</high-units>
<unit-calculator>binary</unit-calculator>
</local-scheme>
</backing-map-scheme>
<autostart>true</autostart>
</transactional-scheme>
<distributed-scheme>
<scheme-name>storage.distributedcache.stt.scheme</scheme-name>
<service-name>storage.distributedcache.stt</service-name>
<serializer>
<class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
<init-params>
<init-param>
<param-type>String</param-type>
<param-value>cnt-pof-config.xml</param-value>
</init-param>
</init-params>
</serializer>
<backing-map-scheme>
<local-scheme>
<high-units>250M</high-units>
<unit-calculator>binary</unit-calculator>
</local-scheme>
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
</caching-schemes>
</cache-config>
Failing code (uses transaction APIs 3.6.0):
public static void main(String[] args)
Connection con = new DefaultConnectionFactory().createConnection("storage.transactionalcache.cnt");
con.setAutoCommit(false);
try
OptimisticNamedCache cache = con.getNamedCache("cnt.t1");
CId tID = new CId();
tID.setId(11111L);
C tC = new C();
tC.setVal(new BigDecimal("100.1"));
cache.insert(tID, tC);
con.commit();
catch (Exception e)
e.printStackTrace();
con.rollback();
finally
con.close();
Code that succeeds (but without transaction APIs):
public static void main(String[] args)
try
NamedCache cache = CacheFactory.getCache("stt.t1");
CId tID = new CId();
tID.setId(11111L);
C tC = new C();
tC.setVal(new BigDecimal("100.1"));
cache.put(tID, tC);
catch (Exception e)
e.printStackTrace();
finally
And here is what we list using coherence console if we use transactional APIs:
Map (cnt.t1): list
CId {
id = 11111
} = null
Any suggestion, please?Cristian,
After looking at your configuration I noticed that your configuration is incorrect. For a transactional scheme you cannot specify a backing-map-scheme.
Your config contained:
<backing-map-scheme>
<local-scheme>
<high-units>250M</high-units>
<unit-calculator>binary</unit-calculator>
</local-scheme>
</backing-map-scheme>To specify high-units for a transactional scheme, simply provide a high-units element directly under the transactional-scheme element.
<transactional-scheme>
<scheme-name>small-high-units</scheme-name>
<service-name>TestTxnService</service-name>
<autostart>true</autostart>
<high-units>1M</high-units>
</transactional-scheme>http://download.oracle.com/docs/cd/E15357_01/coh.360/e15723/api_transactionslocks.htm#BEIBACHA
The reason that it is not allowable to specify a backing-map-scheme for a transactional scheme is that transactional caches use their own storage.
I am not sure why this would work with primitives and only fail with POF. We will look into this further here and try to reproduce.
Can you please change your configuration with the above changes and let us know your results.
Thanks,
John
Edited by: jspeidel on Sep 16, 2010 10:44 AM -
How to use task flow's transaction options with session's user data
Hi.
I have custom extension of ApplicationModuleImpl class:
package test.model
imports...
public class CustomAppModuleImpl extends ApplicationModuleImpl {
public static final String SESSION_VAR = "MySessionVar";
public CustomAppModuleImpl() {
super();
@Override
protected void prepareSession(Session session) {
super.prepareSession(session);
System.out.println("######## " + this.getClass().getName() + ".prepareSession() called. AM isRoot() = " + isRoot());
Hashtable userData = session.getUserData();
if (userData == null) {
userData = new Hashtable();
userData.put(SESSION_VAR, "Useless");
@Override
protected void create() {
super.create();
System.out.println("######## " + this.getClass().getName() + ".prepareSession() called. AM isRoot() = " + isRoot());
}Inside userData I store some useful session-based values (here is just an example ;) ).
Within Model.jpr I defined that every Application Module I create must extends this CustomAppModuleImpl :
<value n="oracle.jbo.extends.appModule" v="test.model.CustomAppModuleImpl"/>
...I have one AM with one view:
package test.model;
import oracle.jbo.server.ViewObjectImpl;
// --- File generated by Oracle ADF Business Components Design Time.
// --- Wed Mar 07 20:22:11 CET 2012
// --- Custom code may be added to this class.
// --- Warning: Do not modify method signatures of generated methods.
public class AppModule1Impl extends CustomAppModuleImpl {
* This is the default constructor (do not remove).
public AppModule1Impl() {
* Container's getter for EmployeesView1.
* @return EmployeesView1
public ViewObjectImpl getEmployeesView1() {
return (ViewObjectImpl)findViewObject("EmployeesView1");
}Now I have BTF (bounded task flow, with default properties) and I call that task flow on a button press. With default properties ( Transaction: <No Controller Transaction> ) I get preferred values from session's userData within Entity Object.
Code snippet inside that entity implementation looks like:
DBTransaction dbt = getDBTransaction();
System.out.println(getClass().getName() + " entity lives AM: " + dbt.getRootApplicationModule().getClass().getName());
if (dbt.getSession().getUserData() == null) {
System.out.println(CustomAppModuleImpl.SESSION_VAR + " -> NULL");
} else {
System.out.println(CustomAppModuleImpl.SESSION_VAR + " -> " + dbt.getSession().getUserData().get(CustomAppModuleImpl.SESSION_VAR));
...And as I mentioned output is correct:
test.model.EmployeesImpl entity lives AM: test.model.AppModule1Impl
MySessionVar -> UselessNow the trickiest part. As soon as I change property of called task flow Transaction to something else that +<No Controller Transaction>+, e.g. Always Begin New Transaction, code snippet from task-flow.xml :
<transaction>
<new-transaction/>
</transaction>
..This session stuff begin to act unpredictably. Session's userData is now null. And Output looks like:
test.model.EmployeesImpl entity lives AM: oracle.jbo.server.ApplicationModuleImpl
MySessionVar -> NULLWhy in the world ADF uses oracle.jbo.server.ApplicationModuleImpl instead of test.model.AppModule1Impl or at least my defined test.model.CustomAppModuleImpl ?!?
Is this a bug? Or maybe a feature?
10x
RegardsHi,
Why in the world ADF uses oracle.jbo.server.ApplicationModuleImpl instead of test.model.AppModule1Impl or at least my defined test.model.CustomAppModuleImpl ?!?
Is this a bug? Or maybe a feature?
ADF BC alwyas has a transaction opened even if the ADFc setting is No Transaction. So if you explicitly ask for a new transaction I assume that the ADF BC data control creates a new transaction without re-executing your AM initialization codes. Looks as if it uses an internal AM instance for this just to hold the transaction. However, worth filing this as a bug - assuming you reproduced this with a later version of either JDeveloper 11g R1 or R2
Frank -
No of transactions in BDC session
Hi
Do we have any limitation on no of transaction a single session can handle. I mean I have writtena BDC and I am running it using generate session method, which will generate a session in sm35. I have more than 2 million reocrds to update. which means that tcode needs to be executed that many times. Does it create any problem
thanks
sankarHi
I am working with r/3 version 4.6 B . I ma using gui_upload to read the data froma text file from desktop. the text file contains tow columns of data separated by tab space. when i pass this to the gui_upload the two columns data is going into first column of the internal table. the code is shown below
DATA : BEGIN OF itab_bdc OCCURS 0,
konob LIKE table-konob,
matnr LIKE table-matnr,
END OF itab_bdc
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file1
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
read_by_line = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = itab_bdc
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
when i see the internal table itab_bdc the field konob contains both the columns data of the text file. It is not splitting the konob and matnr data into two different columns. what shd i do ??
thanks
sankar -
Transactional Caches and Write Through
I've been trying to implement the use of multiple caches, each with write through, all within a transaction.
The CacheFactory.commitTransactionCollection(..) method only seems to work correctly if the first transactionMap throws an exception in the database code.
If the second transactionMap throws exceptions, the caches do not appear to rollback correctly.
I can wrap the whole operation in a JDBC transaction that rolls back the database correctly but the caches are not all rolled back because they are committed one by one?
For example, I write to two transaction maps, each one created from separate caches. When commiting the transaction maps, the second transaction map causes a database exception. It appears the first transaction map has already committed its objects and doesn't roll back.
Is it possible to use Coherence with multiple transaction maps and get all the caches and databases rolled back?
I've also been trying to look at using coherence-tx.rar as described in the forums within WebLogic but I'm getting @@@@@ Failed to commit: javax.transaction.SystemException: Could not contact coordinator at null+SMARTPC:7001+null+t3+
(SMARTPC being my pc name)
Has anybody else had this problem? Bonus points for describing how to fix it!
MikeThe transaction support in Coherence is for Local > Transactions. Basically, what this means is that the
> first phase of the commit ("prepare") acquires locks
> and ensures that there are no conflicts. The second
> phase ("commit") does nothing but push data out to
> the caches.
This means that once prepare succeeds (all locks acquired), commit will try to copy local data into the base map. If there is a failure on any put, rollback will undo any changes made. All locks are cleared at the end.
> The problem is that when you are using a
> CacheStore module, the exception is occurring during
> the second phase.
If you start using a CacheStore module, then database update has to be part of the atomic procedure.
>
> For this reason, write-through and cache transactions
> are not a supported combination.
This is not true for a cache transaction that updaets a single cache entry, right?
>
> For single-cache-entry updates, CacheStore operations
> are fully fault-tolerant in that the cache and
> database are guaranteed to be consistent during any
> server failure (including failures during partial
> updates). While the mechanisms for fault-tolerance
> vary, this is true for both write-through and
> write-behind caches.
For the write-thru case, I believe Database and cache are atomically updated.
> Coherence does not support two-phase CacheStore
> operations across multiple CacheStore instances. In
> other words, if two cache entries are updated,
> triggering calls to CacheStore modules sitting on
> separate servers, it is possible for one database
> update to succeed and for the other to fail.
But once we have multiple CacheStore modules, then once one atomic write-thru put succeeds that means database is already updated for that specific put. There is no way to roll back the database update (although we can roll back the cache update). Therefore, you may end up in partial commits in such situations where multiple cache entries are updated across different CacheStore modules.
If I use write-behind CacheStore modules, I can roll back entirely and avoid partial commits? Since writes are not immediately propagated to the database? So in essence, write-behind cache stores are no different than local transactions... Is my understanding correct? -
12.1.4 build 53 Transaction caching problem
Hello,
I am seeing something new with this 12.1 .
When ever i call a transaction within a transaction repetitively...(may be 5000 times), I see all the calls are recorded in the transaction manager .. and this is loading the XMII_Transaction_Cache table in the database...
It's also keeping a log of all the tracer output.
How to turn this off?
because, this set up is loading the DB heavilly and crashing the system.
Regards,
PramodHi.
First of all you should try and upgrade to at least MII SP5, this is a bit different in handling this. Second you can try one of two things.
If I remember right, the old TRX action block contains a parameter, where you can link the persist parameter, the new trx action block contains a config. parameter, where you can set the value. This will make the caching delete the record every 5 minutes or so. Or second, you can add the persist = onerror to the URL where you call the trx. from or if you schedule it.
But I think that the new version is different in handling this, and do not save the intermediate action calls at all i no error occours.
BR
Poul. -
JDO transaction, caching and stored procedures
I currently retreive an existing object, update the object, and then call
a stored procedure - all in one transaction. The issue I am running into
is that the stored proc must have the modified data available when it
selects the row (modified object) from the table. This is currently not
happening. For example, if the initial field was null, then it is updated
and the proc called, the proc only sees null. How do I specify that the
changes should be processed w/in the transaction (not commited) and
available for other processes reading the data in the same tx?
Note: everything works perfect if I manually execute the update statement
through a Statement on the connection for the stored proc. I have tried
flush().
Any ideas would be greatly appreciated!Here is a dumbed down version... I also tried doing a Query with JDO and
that returns the modified value. Basically, the code below find the
existing object, modifies a field, and then calls a stored proc to do some
processing. Unfortunately, the stored proc needs to be able to "see" the
modified data in the transaction.
public void modifyFoo( UserToken userToken,
Foo newFoo,
Integer applicationId )
PersistenceManager pm = null;
Transaction tx = null;
Integer applicationId = producerApplication.getId();
try
pm = JDOFactory.getPersistenceManager( userToken );
tx = pm.currentTransaction();
tx.begin();
FooBoId appId = new FooBoId();
appId.fooBolId = applicationId;
FooBo appDbVo = (FooBo)pm.getObjectById( appId, true );
appDbVo.setEffectiveDate( newFoo.getEffectiveDate() );
String fooNumber = executeFooBar( userToken, applicationId
appDbVo.setFooNumber( fooNumber );
tx.commit();
private String executeFooBar( UserToken userToken, Integer
applicationId )
throws PulsarSystemException, ValidationException
String licenseNumber = null;
try
// Get a connection from the persistence manager
Connection connection = JDOFactory.getConnection( userToken );
connection.setAutoCommit( false );
CallableStatement cs = connection.prepareCall( "{call
sys_appl_pkg.fooBar(?,?,?,?,?,?)}" );
// Register the type of the return value
cs.registerOutParameter( 4, Types.NUMERIC );
cs.registerOutParameter( 5, Types.NUMERIC );
cs.registerOutParameter( 6, Types.VARCHAR );
// Set parameters:
cs.setString( 1, "Test" );
cs.setInt( 2, applicationId.intValue() );
cs.setInt( 3, 0 );
catch( SQLException ex )
ex.printStackTrace();
return licenseNumber;
Patrick Linskey wrote:
Can you post the code that you're executing?
-Patrick
On Mon, 14 Jul 2003 20:38:09 +0000, Josh Zook wrote:
I currently retreive an existing object, update the object, and then call
a stored procedure - all in one transaction. The issue I am running into
is that the stored proc must have the modified data available when it
selects the row (modified object) from the table. This is currently not
happening. For example, if the initial field was null, then it is updated
and the proc called, the proc only sees null. How do I specify that the
changes should be processed w/in the transaction (not commited) and
available for other processes reading the data in the same tx?
Note: everything works perfect if I manually execute the update statement
through a Statement on the connection for the stored proc. I have tried
flush().
Any ideas would be greatly appreciated!
Patrick Linskey
SolarMetric Inc. -
Call transaction in new session not working inside CRM Interaction Center
Hi Experts,
I have developed a report which contains a screen with push button. When user clicks on button a transaction (FPL9) is being called and opened in new session or window. But when the report is being called in CRM Interaction Center using transaction launcher and button is clicked no new session or new window is being opened. Our requirement is FPL9 transaction will be opened in new session / window inside Interaction Center also.
Please help me how to open a new session or window in interaction center on push botton click.
Thanks in advance.
Regards,
ArnabHi Anil..
This is the Solution for ur Requirement. try this program and change as per ur need.
REPORT ZSEL_CALL_TCODE.
data : IT_KNA1 TYPE TABLE OF KNA1 WITH HEADER LINE.
DATA : IT_SPA TYPE TABLE OF RFC_SPAGPA WITH HEADER LINE.
SELECT * FROM KNA1 INTO TABLE IT_KNA1 .
LOOP AT IT_KNA1 .
WRITE:/ IT_KNA1-KUNNR HOTSPOT ON.
HIDE IT_KNA1-KUNNR .
ENDLOOP.
CLEAR IT_KNA1-KUNNR.
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.
IF IT_KNA1-KUNNR IS NOT INITIAL.
REFRESH IT_SPA.
IT_SPA-PARID = 'KUN'.
IT_SPA-PARVAL = IT_KNA1-KUNNR.
APPEND IT_SPA.
CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'S1'
EXPORTING
TCODE = 'XD02'
SKIP_SCREEN = ' '
MODE_VAL = 'A'
UPDATE_VAL = 'A'
IMPORTING
SUBRC =
TABLES
USING_TAB =
SPAGPA_TAB = IT_SPA
MESS_TAB =
EXCEPTIONS
CALL_TRANSACTION_DENIED = 1
TCODE_INVALID = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDCASE.
<b>Reward if Helpful.</b> -
Call transaction in new session with the value at hotspot
Hi all,
As a hotspot functionality I would like to open a new transaction in a new session with the value at hotspot. For that reason, I am using the FM ABAP4_CALL_TRANSACTION with the option STARTING NEW TASK.
This FM is not working because Parameter ID is not Maintained for the field (Hotspoted). So no value is passing to new transaction.
Please suggest any other way to implement this.
ThanksHi Anil..
This is the Solution for ur Requirement. try this program and change as per ur need.
REPORT ZSEL_CALL_TCODE.
data : IT_KNA1 TYPE TABLE OF KNA1 WITH HEADER LINE.
DATA : IT_SPA TYPE TABLE OF RFC_SPAGPA WITH HEADER LINE.
SELECT * FROM KNA1 INTO TABLE IT_KNA1 .
LOOP AT IT_KNA1 .
WRITE:/ IT_KNA1-KUNNR HOTSPOT ON.
HIDE IT_KNA1-KUNNR .
ENDLOOP.
CLEAR IT_KNA1-KUNNR.
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.
IF IT_KNA1-KUNNR IS NOT INITIAL.
REFRESH IT_SPA.
IT_SPA-PARID = 'KUN'.
IT_SPA-PARVAL = IT_KNA1-KUNNR.
APPEND IT_SPA.
CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'S1'
EXPORTING
TCODE = 'XD02'
SKIP_SCREEN = ' '
MODE_VAL = 'A'
UPDATE_VAL = 'A'
IMPORTING
SUBRC =
TABLES
USING_TAB =
SPAGPA_TAB = IT_SPA
MESS_TAB =
EXCEPTIONS
CALL_TRANSACTION_DENIED = 1
TCODE_INVALID = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDCASE.
<b>Reward if Helpful.</b> -
Call transaction in new session (but only one)
Dear all,
as a hotspot functionality I would like to open a new transaction in a new session. For that reason, I use the FM ABAP4_CALL_TRANSACTION with the option STARTING NEW TASK.
However I would like to restrict the new tasks in a way that only one session is used (no matter how often the user clicks the hotspot. Kind of like the ABAP Help in the workbench.
I checked the class CL_IMC_MODE to see if it could work as a new internal session but the new mode dumped when I pressed the back button and according to the dump Statements that closes the internal mode unexpectedly like LEAVE are not allowed. Since I call standard transactions (like VA03) I can hardly prevent that. Did I miss something or do you have any other idea how I could solve my problem?
Thank you for any input.
ChristianHi Christian,
Here is a sample code that takes in a sales order number, displays the document number as hotspot and when the user clicks on the hotspot, it opens a new window for displaying the order. No matter how many times the user clicks on the hotspot, it will only display one window for VA03. I hope this solves your problem.
REPORT ztest.
PARAMETERS: p_vbeln LIKE vbak-vbeln.
DATA: ls_vbak LIKE vbak.
DATA: BEGIN OF i_rfc_spagpa OCCURS 0.
INCLUDE STRUCTURE rfc_spagpa.
DATA: END OF i_rfc_spagpa.
DATA: v_mode LIKE sy-index.
START-OF-SELECTION.
SELECT SINGLE * FROM vbak
INTO ls_vbak
WHERE vbeln = p_vbeln.
IF sy-subrc <> 0.
*-- error.
ENDIF.
WRITE:/ ls_vbak-vbeln HOTSPOT,
ls_vbak-vkorg.
AT LINE-SELECTION.
CASE sy-ucomm.
WHEN 'PICK'.
*-- Delete the previous session and then call VA03 in a new session
CALL FUNCTION 'TH_DELETE_MODE'
EXPORTING
mode = v_mode.
CLEAR: i_rfc_spagpa, i_rfc_spagpa[].
i_rfc_spagpa-parid = 'AUN'.
i_rfc_spagpa-parval = p_vbeln.
APPEND i_rfc_spagpa.
CLEAR i_rfc_spagpa.
CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'TEST'
EXPORTING
tcode = 'VA03'
skip_screen = 'X'
mode_val = 'A'
update_val = 'A'
* IMPORTING
* SUBRC =
TABLES
* USING_TAB =
spagpa_tab = i_rfc_spagpa
* MESS_TAB =
EXCEPTIONS
call_transaction_denied = 1
tcode_invalid = 2
OTHERS = 3 .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
WHEN OTHERS.
ENDCASE. -
Handling Transaction in Stateful Session Bean
I wrote a public method like public void doTransaction()
it will call 2 private method, like: methodA and methodB
Both private methods have db accesss statement and will update the db. They got different db connection and will close the connection when method call finished.
How to include them to one transaction? I want to be able to rollback the job of the first method when I catch exception thrown by the second method.
I tried simply define transaction type of the public method to be Container and Required. But it doesn't work, the first method doesn't rollback. Of course I can let the 2 private methods share a same connection and commit after finishing calling them. But how if they are in different DB?Ok... Here it goes...
You can do it in the following manner.
As you said you have got 2 private methods doing d/b updates and these are called from a public method.
Stateful session beans since associated with a client across methods, you can take advantage of it. Write your own user defined transaction.
Begin the transaction scope in your public before calling the 1st private method. Call the 2 methods in a try block. Once you are done with these methods, you can commit and end the transaction. If you get any exception, rollback the transaction in the catch block. Otherwise if u get any exception in the 2nd method, you can rollback the transaction there itself.
Stateful session beans lets u allow to spawn the bean managed transaction across methods. you can begin your transaction in one method and end it in a differnt method or you can end the transaction after calling the methods.
The problem you are dealing with can typically very well handled by writing bean managed transaction.
Hope this helps. If you need anymore clarity on my solution, please let me know.
-amit -
Transaction Problem in Session Facade Design Pattern
Hi
Well Sorry for giving wrang title to the topic, coz of which I have not received and reply.
I am using session facade design pattern.
I have Action class calling session facade method "getData" . This method calls "findByPrimaryKey" method in BMP.
Method "getData" has transaction attribute as "RequiresNew" and "findByPrimaryKey" has "Required".
This combination does not assign identity to BMP hence I can not use setter getter method for retriving data(throws nullpointer exception when getter method accessed) I have made sure that I am accessing table and getting data in to BMP but as BMP is not ablle to hoild any identity its not allowing me to use BMP's getter method in session facade.
I have Used Same transaction attribute for create method called by "addNew" method of session facade bean.
Transaction method for "addNew" is "RequiresNew" and for "create" is "Required".
It works fine and gives identity toBMP hense I can use Setter getter method defined in BMP bean.
How can I avoid this and get BMP an identity?
Thanking in Advance,
Chintan.Sorry, how is this related to JSF?
There's an OO/patterns forum out. Consider reposting the question over there with formatted code. -
How to call Custom screen in standard transaction on same session
Hi ,
I am getting this Problem.
After one of the screen in standard Transaction (CV01N) I need to call one custom screen. for this I created one program type M with screen. in Stan. transaction I am calling like Call transaction 'XXXX'(for above M program).here I am geeting all my required functionality .but I am getting this custom screen in separate session. I want to call this custom screen on same session of std transaction ( means background custom screen is std.screen).
Can any one guide me to achive this functionality;
Regards,
Saida.Hi Agasti,
Thnx for your reply.
I tried that method also. even that also calling the Custom screen in new session not in SAP standard session.
Regards,
Saida -
Rollback a transaction in a session bean BMP?
The following code would work correctly if executed in a stateless session bean BMP?
InitialContext ic = new InitialContext();
javax.sql.DataSource dataSource = (javax.sql.DataSource) ic.lookup("java:comp/env/jdbc/OracleDS");
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
Statement stmt = conn.createStatement("UPDATE TABLE_A SET NAME = 'Duke' WHERE ID = 7");
stmt.executeUpdate();
if (someCondition) {
conn.commit();
} else {
conn.rollback();
My question:
It�s possible to rollback a transaction using rollback() from Connection class in a stateless
session bean BMP?Dear JDC member:
With EJB, you can gain the benefit of transactions without performing any transaction programming. That is, your enterprise beans never explicitly issue a begin, commit, or abort statement. The container performs it to you. But you have to tell the container how to do it. As you might know, the deploment descriptor is the place for it.
But nothing prevent you to do do programmatic transaction as you want.. For that case you have to know JTA (Java Transaction API) and more.
Suppose the transaction aborts, you have to throw an exception back to the client or try it again. The issue here is with stateless sesssion beans, there is no in-memory conversational state. You might think to implement javax.ejb.SessionSynchronization interface with your business methods....
You see there is a lot to know. You can take care of transactions in the client code, but it is a bad design.
You have to understand today most application servers (Websphere, Weblogic...) are designed to minimize those issues in order to make developers' tasks easier. The container takes care of transactions.
Be careful when you write stateless session beans BMP (BMP are for entiti beans)
Regards,
Armand Komenan -
Transaction using stateful session bean.
All,
I was implementing "Transaction" part using statefull session(trying to understand how transaction work).
I created a Statefull session bean, here in one method create 2 sql queries
query1:update Employees set LastName='newname' where EmployeeID = 9
query2:update Customers set CompanyName = 'newname Inc.' ContactName = 'Maria Anders'
"query1" works fine, but "query2" is not correct(syntax error) hence will not be executed. This will throw a SQLException.
According to EJBspec, rollback will happen if there is a system exception. And I guess SQLException is systemexception.
But when I query "Employees" table, I get the data updated through the "query1".
What I was excepting was the first query which was executed should have rolled back because the second query has thrown a SQLException.
I tried using ContainerManaged transaction and BeanManaged transaction.
But in both cases transaction is not getting rolled back.
I have tried with REQUIRED and REQUIRESNEW attributes for container managed transactions with Isolation level as Read Commited.
Is my understanding correct?
TIA,
VijayTried using Bean managed transactions but with the same result. Given below is the sample code.
UserTransaction uts = null;
try {
uts = (UserTransaction)(ctx.getUserTransaction());
uts.begin();
Connection con = null;
con = getCountConnection();
PreparedStatement ps = con.prepareStatement(sqlselectUserId);
ps.executeUpdate();
PreparedStatement ps1 = con.prepareStatement(sqlselectUserDetails);
ps1.executeUpdate();
uts.commit();
catch(SQLException e) {
uts.rollback();
Maybe you are looking for
-
Hi, I was restoring my iPod touch when a message came up on my screen saying 'iPod could not be restored. An unknown error occurred (3014).' I've tried the 'iOS: Resolving update and restore alert messages' tips and nothings helping...HELP!!!
-
I am facing problem with fuzzy PD logic controller for transfer function in control and simulation loop. Plz Help me in this regard................... i have attache snapshot of my program Attachments: fuzzy in simulation loop.JPG 52 KB
-
How to change Windows 7 file associations in the registry
Hi, I have a group of computers that have Office 2010 installed and then PowerPoint Viewer 2007 was installed after that to temporarily resolve an SCCM 2007 patching issue. Needless to say, PowerPoint Viewer 2007 changed some of the PowerPoint 2010 f
-
CRM 5, Segment Builder: Exclude customer already contacted for a campaign
Hi CRM Gurus, I'm working on a CRM 5.0 scenario. When creating a new Target Group we want to exclude all customers previously contacted for an E-mail campaign. Is there a standard feature to do this or do we have to implement a custom solution? In th
-
BO XI Enterprise config prep info
I'm trying to nail down some answers for a client, but running out of time to find this info in the documentation, and would greatly appreciate any full or partial responses to the following. My client would like to install BO XI Enterprise Professio