Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] committing / rollback question + entitymanager

Your config looks correct.

Are you setting a server platform (target-server) or transaction controller
in EclipseLink?

What server are you running on?



Leon Derks-2 wrote:
> 
> Hello
> 
> I use a datasource.
> 
> Here are pieces of my persistence.xml:
> 
> <persistence-unit name="application-web"
> transaction-type="RESOURCE_LOCAL">
> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
> <non-jta-data-source>java:comp/env/jdbc/myDS</non-jta-data-source>
> <property name="eclipselink.target-database" 
> value="org.eclipse.persistence.platform.database.oracle.Oracle10Platform"
> />
> 
> Here is my datasource definition in the tomcat context.xml
> <Resource name="jdbc/myDS" auth="Container"
>         type="oracle.jdbc.pool.OracleDataSource"
>         driverClassName="oracle.jdbc.driver.OracleDriver"
>         factory="oracle.jdbc.pool.OracleDataSourceFactory"
>         url="jdbc:oracle:thin:@//localhost:1521/XE" user="test" 
> password="test"
>         connectionCachingEnabled="true" connectionCacheName="AppCache"
>         connectionCacheProperties="{MaxStatementsLimit=40, MinLimit=0, 
> InitialLimit=0,
>             ValidateConnection=true, ConnectionWaitTimeout=10, 
> MaxLimit=20}" />
> 
> web.xml:
>  <resource-ref>
>         <description>Resource reference to the application 
> Datasource</description>
>         <res-ref-name>jdbc/myDS</res-ref-name>
>         <res-type>javax.sql.DataSource</res-type>
>         <res-auth>Container</res-auth>
>     </resource-ref>
> 
> Is there something wrong with this configuration?
> 
> Leon
> 
> James Sutherland wrote:
>> My guess would be that you have configured EclipseLink with a JTA
>> DataSource,
>> but the DataSource that you are using is not JTA.
>>
>> Otherwise something very odd is occurring.   Perhaps include your
>> persistence.xml, and enable logging on finest to see when your
>> transaction
>> is begun/committed, it seems your connection is somehow being left in
>> auto-commit mode, or perhaps your database does not support transactions.
>>
>>
>>
>> Leon Derks-2 wrote:
>>   
>>> Hello
>>>
>>> I have a problem with the rollback of my transaction. For some reason 
>>> the entities are saved in the db while the transaction has not
>>> committed.
>>>
>>> These are the steps:
>>>
>>> try{
>>>     logger.debug(" Starting a transaction");
>>>     entityManager.getTransaction().begin();
>>>             //here do some entityManager.persist(entities);
>>>            //then throw a runtime exception to fake an exception.
>>>      logger.debug("Committing the transaction");
>>>      entityManager.getTransaction().commit();
>>> catch(Exception e) {
>>>     logger.error(e);
>>> }
>>> finally {
>>>      if (entityManager != null && 
>>> entityManager.getTransaction().isActive()) {
>>>                 logger.debug("Rolling back the transaction");
>>>                 entityManager.getTransaction().rollback();
>>> }
>>>
>>> This is my logging info:
>>> Starting a transaction
>>>         exception stacktrace...........
>>> Rolling back the transaction
>>>
>>> As you can see the transaction is not committed but rolled back. However 
>>> there are entities in my db.
>>>
>>> How is this possible?
>>> Leon
> 


-----
---
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://www.nabble.com/committing---rollback-question-%2B-entitymanager-tp17665391p17732534.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top