diff --git a/pom.xml b/pom.xml index 7271895..ef2f1f2 100755 --- a/pom.xml +++ b/pom.xml @@ -53,8 +53,8 @@ - 3.2.8.RELEASE - 1.5.2.RELEASE + 3.2.9.RELEASE + 1.6.0.RELEASE 1.7.2 UTF-8 diff --git a/src/main/java/org/springframework/data/envers/repository/support/EnversRevisionRepositoryFactoryBean.java b/src/main/java/org/springframework/data/envers/repository/support/EnversRevisionRepositoryFactoryBean.java index 0e48ea1..40281a7 100755 --- a/src/main/java/org/springframework/data/envers/repository/support/EnversRevisionRepositoryFactoryBean.java +++ b/src/main/java/org/springframework/data/envers/repository/support/EnversRevisionRepositoryFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,10 @@ import javax.persistence.EntityManager; import org.hibernate.envers.DefaultRevisionEntity; import org.springframework.beans.factory.FactoryBean; import org.springframework.core.GenericTypeResolver; -import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.support.JpaEntityInformation; import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean; +import org.springframework.data.jpa.repository.support.SimpleJpaRepository; import org.springframework.data.repository.core.RepositoryMetadata; import org.springframework.data.repository.core.support.RepositoryFactorySupport; import org.springframework.data.repository.history.RevisionRepository; @@ -88,7 +88,7 @@ public class EnversRevisionRepositoryFactoryBean extends */ @Override @SuppressWarnings({ "unchecked", "rawtypes" }) - protected JpaRepository getTargetRepository(RepositoryMetadata metadata, + protected SimpleJpaRepository getTargetRepository(RepositoryMetadata metadata, EntityManager entityManager) { JpaEntityInformation entityInformation = (JpaEntityInformation) getEntityInformation(metadata diff --git a/src/test/java/org/springframework/data/envers/Config.java b/src/test/java/org/springframework/data/envers/Config.java index ac55029..b0fabf5 100755 --- a/src/test/java/org/springframework/data/envers/Config.java +++ b/src/test/java/org/springframework/data/envers/Config.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ import java.sql.SQLException; import java.util.Collections; import java.util.Map; -import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.hibernate.envers.strategy.ValidityAuditStrategy; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; @@ -40,6 +41,7 @@ import org.springframework.transaction.PlatformTransactionManager; * @author Oliver Gierke */ @Configuration +@EnableJpaRepositories(repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class) public class Config { @Bean @@ -49,13 +51,11 @@ public class Config { @Bean public PlatformTransactionManager transactionManager() throws SQLException { - - EntityManagerFactory entityManagerFactory = entityManagerFactoryBean().getObject(); - return new JpaTransactionManager(entityManagerFactory); + return new JpaTransactionManager(); } @Bean - public AbstractEntityManagerFactoryBean entityManagerFactoryBean() throws SQLException { + public AbstractEntityManagerFactoryBean entityManagerFactory() throws SQLException { HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter(); jpaVendorAdapter.setDatabase(Database.H2); diff --git a/src/test/java/org/springframework/data/envers/repository/support/RepositoryIntegrationTest.java b/src/test/java/org/springframework/data/envers/repository/support/RepositoryIntegrationTest.java index 1299b1e..a42ce9a 100755 --- a/src/test/java/org/springframework/data/envers/repository/support/RepositoryIntegrationTest.java +++ b/src/test/java/org/springframework/data/envers/repository/support/RepositoryIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +25,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.envers.Config; @@ -38,7 +36,6 @@ import org.springframework.data.history.Revision; import org.springframework.data.history.Revisions; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; /** * Integration tests for repositories. @@ -46,19 +43,11 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; * @author Oliver Gierke */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(loader = AnnotationConfigContextLoader.class) +@ContextConfiguration(classes = Config.class) public class RepositoryIntegrationTest { - @ImportResource("classpath:application-context.xml") - @Configuration - static class RepoConfig extends Config { - - } - - @Autowired - LicenseRepository licenseRepository; - @Autowired - CountryRepository countryRepository; + @Autowired LicenseRepository licenseRepository; + @Autowired CountryRepository countryRepository; @Before public void setUp() { diff --git a/src/test/resources/application-context.xml b/src/test/resources/application-context.xml deleted file mode 100755 index 2386709..0000000 --- a/src/test/resources/application-context.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - -