[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-dev] Error in EMQueryJUnitTestSuite.testcreateNativeQueryWithSelectSQL on SAP NetWeaver
|
Hi Tom,
We did find the test error on other servers, but we haven't had time to
fix it yet. so the testcase needs to be fixed like:
// this may fail with some drivers
int result = 0;
try {
result = query1.executeUpdate();
} catch (RuntimeException ex) {
rollbackTransaction(em);
closeEntityManager(em);
em = createEntityManager();
beginTransaction(em);
}
Yiping
On 11/26/2009 10:10 AM, Tom Ware wrote:
If the entity manager is transaction scoped, I think Sabine is right.
The entity manager should be closed when the transaction either
commits or rolls back. I wonder why that is not happening on other
servers. (you'll notice query1.executeUpdate() is designed to fail)
-Tom
yiping zhao wrote:
Hi Sabine,
In the test framework, by default the entity manager is injected in
sessionbean, it's transaction-scoped.
>From the stacktrace, it looks like that there is issue when
executing "result = query1.executeUpdate();", then somehow your SAP
NetWeaver application server closes the entity manager, after that
you get the exception "java.lang.IllegalStateException: Attempting to
execute an operation on a closed EntityManager" when executing
"query2.executeUpdate();", so this sounds like a server issue.
Yiping
On 11/26/2009 4:34 AM, Heider, Sabine wrote:
Hi Tom,
I'm not really familiar with the details of test framework either,
but I guess the entity manager is taken from the TestRunnerBean:
@Stateless(name="TestRunner", mappedName="TestRunner")
@Remote(TestRunner.class)
@TransactionManagement(TransactionManagementType.BEAN)
public class TestRunnerBean implements TestRunner {
/** The entity manager for the test is injected and passed
to the test server platform. */
@PersistenceContext
private EntityManager entityManager;
/** The entity manager factory for the test is injected and
passed to the test server platform. */
@PersistenceUnit
private EntityManagerFactory entityManagerFactory;
So yes, it is transaction-scoped.
Best regards,
Sabine
-----Original Message-----
From: eclipselink-dev-bounces@xxxxxxxxxxx
[mailto:eclipselink-dev-bounces@xxxxxxxxxxx] On Behalf Of Tom Ware
Sent: Mittwoch, 25. November 2009 14:07
To: Dev mailing list for Eclipse Persistence Services
Subject: Re: [eclipselink-dev] Error in
EMQueryJUnitTestSuite.testcreateNativeQueryWithSelectSQL on SAP
NetWeaver
Hi Sabine,
I am not familiar with how the entity manager for the tests are
created. The part of the spec you are referring to is for
Transaction-scoped entity managers. Is the entity manager used in
this test created in such a way that it will be transaction-scoped
on all servers?
-Tom
Heider, Sabine wrote:
Hi,
I'd like to get your opinion on an error I get when running the JPA
server tests inside an SAP NetWeaver application server (stack
shortened, executed on current trunk):
java.lang.IllegalStateException: Attempting to execute an operation
on a closed EntityManager.
at
org.eclipse.persistence.internal.jpa.EntityManagerImpl.verifyOpen(EntityManagerImpl.java:1516)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeUpdate(EJBQueryImpl.java:492)
at
org.eclipse.persistence.testing.tests.jpa.relationships.EMQueryJUnitTestSuite.testcreateNativeQueryWithSelectSQL(EMQueryJUnitTestSuite.java:121)
at
org.eclipse.persistence.testing.framework.junit.JUnitTestCase.runBareServer(JUnitTestCase.java:463)
at
org.eclipse.persistence.testing.framework.server.TestRunnerBean.runTest(TestRunnerBean.java:87)
I run the test against a MySQL database. The MySQL driver throws an
SQLException in EMQueryJUnitTestSuite line 114: Can not issue
executeUpdate() for SELECTs.
Consequently, I end up in the catch block where the current
transaction is rolled back.
Chapter 7.9.1 of the JPA specification says:
"After the JTA transaction has completed (either by transaction
commit or rollback), The container
closes the entity manager by calling EntityManager.close."
Apparently, this is what the JPA container in NetWeaver does. With
the closed entity manager, however, query2 becomes unusable.
In my opinion, it's an error of the test rather than of the JPA
container, but I might be wrong. What do you think?
Thanks and best regards,
Sabine
*Sabine Heider
**SAP AG
*Pflichtangaben/Mandatory Disclosure Statements:
_http://www.sap.com/company/legal/impressum.epx_
------------------------------------------------------------------------
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
------------------------------------------------------------------------
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev