I'm using JPA/Eclipselink in Java SE (Oracle Java 7) and Java EE (Websphere Liberty) environments.
I have a component which is called from both Java SE and Java EE (by component I mean the same source code), which executes JPA queries.
(the Java SE run is started with -javaagent:lib/eclipselink.jar
param)
I have conducted 3 test runs:
- in Java EE - the code runs fast (e.g. queries take around 0.01 seconds)
- in Java SE - the code runs slow (2 seconds/query)
- in Java SE AND Java EE server is running - the code runs as fast as in the first case
I'm a bit puzzled; why does starting up a Java EE server causes code (running in a different JVM) to speed up? And what can I do to speed up the queries in Java SE without running a Java EE server?
UPDATE
This issue might be related to the underlying database. I run the applications in the following order
- started Java SE app - queries are slow
- started Java EE app - queries in Java SE app are fast
- stopped Java EE app - queries are still fast in Java SE app
So, there might be some kind of database cache(?) which the Java EE app initializes, but the Java SE app doesn't - however I don't see anything in the log what might be related to this.
One more thins I saw, is that the two apps use a different database driver (which might cause some performance difference, but wouldn't explain why starting both apps would cause the speed up ...)