Community
Participate
Working Groups
In investigating our Spring tests and trying to get all JPA tests running on Spring, I noticed several issues: - Spring temp class loader excludes org.eclipse.persistence, oracle., this means any EclipseLink test/example using these packages will not weave/work. - Spring ignores exclude-unlisted-classes=false (makes true), the only way to make false is to remove the element entirely. - Spring cannot find jar-file elements on the classpath unless the directory the jars are in are also on the classpath.
These are mainly Spring issues, so there is not much we can do other than logging bugs on Spring, document the issues, or waiting for the Spring 3.0 release to re-test.
Also: - Spring by default calls beginEarlyTransaction on beginTransaction, this will cause the shared cache to effectively be disabled. They seem to do this to be able to have a single JDBC connection used, but seems very odd. If they really need this, would probably be better to use exclusive connection properties.
Setting target and priority. To see what these settings mean see: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Created attachment 147101 [details] adds jpa test support for spring
SVN main commit: Bug#288383 - Spring platform test support - Adds support for running any JPA test on the Spring platform - Added JPA test framework server platform for Spring - Added, build, config files and test persistence.xml for Spring testing - Added system property to set test server platform. - Some JPA test fixes for serverifacation. - Added SQLResultSetMappingTestSuite back to server tests (and fixed deadlock issue) Any of the JPA tests should be able to run with Spring now. You need to set the test server platform system property and add spring to the class path (is a run target in the spring test project). The advanced and field-access tests should all pass except a single legitimate failure. Weaving is currently disabled because of Spring issues in weaving org.eclipse.persistence classes. Other test models will need there own config files.
Removed our temp class loader dependecy to allow weaving of org.eclipse.persistence classes. But found a bigger weaving issue. The spring-agent does not load persistence contexts in premain, only when they get accessed. This can be too late, as the classes can already have been loaded. I added a work around to the tests for this, by forcing loading of the contexts before any test class is loaded, but this can be a major issue for users trying to use Spring. Other workarounds include static weaving or no weaving, or using the eclipselink agent and not using a container factory in Spring.
Created attachment 147367 [details] removes temp class loader dependency from weaving
The hardcoded "C:/Engineering/EclipseLink" spring jar references in the .classpath should be refactored into relative paths
SVN Commit: Bug#288383 https://bugs.eclipse.org/bugs/show_bug.cgi?id=288383 Code Review: Andrei Changes: - Fixed issue of null session in getReference - Moved weaving classes into JPA - Enabled weaving in Spring tests - Added method to initial platform to test framework to allow pre-loading of Spring context - Switched weaving to use meta-data class - Enabled weaving for platforms without a temp class loader - Fixed typo in JPA XML schema loading
Workaround to those who need to get shared cache to work: @Bean public EntityManagerFactory entityManagerFactory() { LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setDataSource(dataSource()); factory.setPersistenceUnitName("main"); Properties jpaProps = new Properties(); jpaProps.put(PersistenceUnitProperties.LOGGING_LOGGER, Slf4jSessionLogger.class.getName()); jpaProps.put(PersistenceUnitProperties.ORDER_UPDATES, "true"); jpaProps.put(PersistenceUnitProperties.UPPERCASE_COLUMN_NAMES, "true"); factory.setJpaProperties(jpaProps); final EclipseLinkJpaDialect customDialect = new EclipseLinkJpaDialect() { @Override public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly) throws PersistenceException, SQLException { // Hides: return super.getJdbcConnection(entityManager, readOnly); return null; } }; customDialect.setLazyDatabaseTransaction(true); EclipseLinkJpaVendorAdapter customAdapter = new EclipseLinkJpaVendorAdapter() { @Override public JpaDialect getJpaDialect() { return customDialect; } }; customAdapter.setDatabase(Database.ORACLE); factory.setJpaVendorAdapter(customAdapter); factory.afterPropertiesSet(); return factory.getObject(); }
(In reply to James Sutherland from comment #0) > - Spring ignores exclude-unlisted-classes=false (makes true), the only way > to make false is to remove the element entirely. I just opened bug #449800 to notify that this is not true since Spring 3.2.4 and 4.0.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink