Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Transactional Context

A SessionBean method should be within a transaction.  You have probably not
configured something correctly.

Ensure you are using a JTA DataSource and JTA transaction type in your
persistence.xml.  Ensure that your server's DataSource is JTA.  Also ensure
that your database supports transactions correctly.

Also check that you have not configured transaction on your SessionBean as
bean managed.

Include your persistence.xml and session bean code, and what database and
server you are using.



Tanujit Chowdhury wrote:
> 
> Hi,
> I have a Stateless SessionBean (SSB) and I am injecting the
> @PersistanceContext inside the bean and using it in the method call. I am
> not using any ContextFactory to create that @PersistanceContext.
> Suppose I have a method A() on the SSB which need to run two queries one
> by
> one. The first query is to INSERTa row in a table using JPQL and the
> injected @PersistanceContext and the second query is to DELETEanother row
> from another table.
> I want both these queries run in the same transaction unit so that if the
> second query (DELETE) fails for some reason then the first query (INSERT)
> also rolls back.
> I think the bean method is running under the same transactional context
> but
> have observed that even if the second query fails the first query INSERts
> data into the table.
> 
> How to prevent this?
> 
> -- 
> Tanujit Chowdhury
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/Transactional-Context-tp29464434p29522824.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top