Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Transactions not working in eclipselink(Transactions not working in eclipselink)
Transactions not working in eclipselink [message #1858048] Mon, 13 March 2023 11:05 Go to next message
Sanjana C is currently offline Sanjana CFriend
Messages: 10
Registered: December 2022
Junior Member
We are working on Migration of Toplink to Eclipselink in our project.

We are extending base Junit class with AbstractTransactionalDataSourceSpringContextTests class from spring 2.0 in our existing Project which has many convenient methods to handle transactions(end transaction,start transaction).

So Same class I am trying to use to test the transactions after migrating to eclipselink but the transactions are not getting committed. The reason I can see from debug is TransactionStatus does not hold the object that needs to be persisted. I have highlighted the UnitOfWork which gets changed while executing the query and committing the transaction in Eclipsselink_UOW.PNG .

I have also tried with @Transactional annotation and AbstractTransactionalJUnit4SpringContextTests from spring 5 but I can see transactions are not getting committed.

FYI:

In persistence.xml

<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<!-- <class>group.id.domain.Staaten</class>
<class>group.id.domain.ClientsystemeImpl</class>-->
<class>de.bund.bamf.InGe.bo.impl.StaatenImpl</class>
<exclude-unlisted-classes />
<shared-cache-mode>NONE</shared-cache-mode><!-- true</exclude-unlisted-classes> -->
<properties>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@****" />
<property name="javax.persistence.jdbc.user" value="***" />
<property name="javax.persistence.jdbc.password" value="***" />
<!-- EclipseLink should create the database schema automatically -->
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="ALL" />
<property name="eclipselink.logging.parameters" value="true" />
<!-- from iau-maris-opa -->
<property name="eclipselink.jdbc.bind-paramaters" value="true" />
<property name="eclipselink.target-database" value="Oracle" />
<property name="eclipselink.persistence-context.flush-mode" value="commit" />
<property name="eclipselink.persistence-context.reference-mode" value="WEAK" />
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.weaving.eager" value="true" />
<!--<property name="eclipselink.cache.shared.default" value="true"/>-->
</properties>
</persistence-unit>
</persistence>


And for transaction manager in springxml:

<?xml version="1.0" encoding="windows-1252"?> <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">


<context:component-scan base-package="org.example"/> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

<property name="persistenceXmlLocation" value="classpath:persistence.xml" />
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitName" value="persistenceUnit" />

<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="showSql" value="true"/>
<property name="generateDdl" value="true"/>
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.SQLServerPlatform"/>
</bean>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
</property>
<!--<property name="jpaPropertyMap">
<props>
<prop key="eclipselink.weaving">false</prop>
</props>
</property>-->

</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven proxy-target-class="true"
transaction-manager="transactionManager" />

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="username" value="${}" />
<property name="password" value="${}" />
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="${*}" />
</bean>

</beans>


Am I missing any property to set ? Or is there any other way to be tested for eclipselink Could you please help me out on this as I am struct here to progress further?
Re: Transactions not working in eclipselink [message #1858050 is a reply to message #1858048] Mon, 13 March 2023 12:26 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 32866
Registered: July 2009
Senior Member
It's best to ask here:

https://www.eclipse.org/forums/index.php?t=thread&frm_id=111


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic: Eclipse for Scientific Computing 2022-23 doesn't support SDM
Next Topic:falling at the first hurdle
Goto Forum:
  


Current Time: Thu Jul 13 03:43:14 GMT 2023

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

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

Back to the top