Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Howto call nontransactional Call in JTA Environment?(Howto call nontransactional Call in JTA Environment? Help Reuqired!)
Howto call nontransactional Call in JTA Environment? [message #509416] Fri, 22 January 2010 12:02 Go to next message
Jan Junker is currently offline Jan Junker
Messages: 6
Registered: January 2010
Junior Member
Hi,
I have a big problem and hope someone can help me!

I'm using Eclipselink 1.1.2 in a JBoss 5.1 environment against a Oracle 10g db. I'm using the BOSS JTA controller. My business logic (db access) is split in normal JPA persistent entities and stored procedures. My persistance.xml defines a jta-data-source and a non-jta-data-source but only one persistence unit.

Now I want some procedures allow to explicitly call commit and rollback (you can see it as a kind of asynchronous execution). These procedures are called as a DataModifyQuery in a ClientSession without UOW (the transaction participating procedures are executed as DataModifyQuery in an UOW).
When I call the commit, I receive an ORA-02089 (commit not allowed in subordinated session).

This pattern worked in my old environment (TopLink 9.0.4.5 and OC4J). Now I'm stuck and really need help how to enabled stored procedures to commit by themselves (perhaps execute them on the non-jta-data-source, but how?) Any ideas?
Re: Howto call nontransactional Call in JTA Environment? [message #509913 is a reply to message #509416] Mon, 25 January 2010 18:42 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

How are you executing the out of transaction queries?

A JPA EntityManager will always execute a query that uses executeUpdate() using the transactional connection. You could try setting the "eclipselink.read-only" query hint, that may work.

You also access the ClientSession directly from the EntityManager.

You could also suspend the current JTA transaction or call a SessioBean method configured with requiresNew.


James : Wiki : Book : Blog : Twitter
Re: Howto call nontransactional Call in JTA Environment? [message #510017 is a reply to message #509416] Tue, 26 January 2010 09:00 Go to previous messageGo to next message
Jan Junker is currently offline Jan Junker
Messages: 6
Registered: January 2010
Junior Member
Hi James,
thanks for your answer, I already though noone would ever answer.

In die Toplink 9.0 code, I was using the following:
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName(this.procedureName);
DataModifyQuery query = new DataModifyQuery();
query.setCall(call);

SessionManager manager = SessionManager.getManager().getSession(sessionname);
ClientSession clientSession = serverSession.acquireClientSession();
Number success = (Number) clientSession.executeQuery(query, values);

This did the job. I was able to call commit and rollback in the stored procedure.

The call is embedded in the logic as follows: an EJB with transaction type required receives the call and does the following described in pseudo code:
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void doSomething() {
   storeEntity1(); // transactional
   callStoredProcedure(); // non transactional
   updateEntity2(); // transacitonal
}

The problem is, that we are migrating our software to eclipselink and this stored procedure pattern is implemented all over the software, to source out the SP-calls to a separate EJB call would be quite a lot work.

Currently, I am experimenting with changing the login of the acquired session to a non-jta data source and removing the transaction controller from the connection (would be the same effect as the query hint, wouldn't it?), this works that far, that I receive a connection from the right pool, but when commiting, I always receive the ORA error saying that no commit is allowed in a subordinated session. Thus, I am still stuck.
Re: Howto call nontransactional Call in JTA Environment? [message #510065 is a reply to message #509416] Tue, 26 January 2010 13:05 Go to previous message
Jan Junker is currently offline Jan Junker
Messages: 6
Registered: January 2010
Junior Member
I finally found a way, but I'm quite sure it's only a hack. Doing it this way, I am able to execute a commit and rollback in the stored procedure and the other calls get handled by the JTA Transaction Manager.

DataSource dataSource = ServerServiceLocator.getInstance().getDataSource("java:/jdbc/NonJtaDS");
JNDIConnector connector = new JNDIConnector(dataSource);
connector.setLookupType(JNDIConnector.STRING_LOOKUP);
connector.setName("java:/jdbc/NonJtaDS");
						
DatabaseLogin login = new DatabaseLogin(new Oracle10Platform());
login.setConnector(connector);
login.setUsesExternalTransactionController(false);
login.dontUseExternalTransactionController();

ConnectionPolicy policy = new ConnectionPolicy();
policy.setExclusiveMode(ExclusiveMode.Always);
policy.setLogin(login);
policy.setPoolName(null);

SessionManager manager = SessionManager.getManager();
Server serverSession = (Server) manager.getSession("sessionname");
						
ClientSession clientSession = serverSession.acquireClientSession(policy);
clientSession.setExternalTransactionController(null);
try {
    Number isValid = (Number) clientSession.executeQuery(query, values);
} finally {
    // release the session otherwise you'll have a connection leak
    clientSession.release();
}


What do you think about this?

[Updated on: Fri, 29 January 2010 08:50]

Report message to a moderator

Previous Topic:aspectj
Next Topic:Type conversion Oracle NVARCHAR2
Goto Forum:
  


Current Time: Tue Oct 21 02:22:31 GMT 2014

Powered by FUDForum. Page generated in 0.08682 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software