Commit c83715cf authored by Maxym Borodenko's avatar Maxym Borodenko

Hibernate 5

- change default setting
- return back old propagation
parent 1b78e1f8
......@@ -53,6 +53,7 @@ import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor;
import org.hibernate.Transaction;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.resource.transaction.spi.TransactionStatus;
import org.hibernate.type.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -746,7 +747,7 @@ public class AuditTrailInterceptor extends EmptyInterceptor implements Initializ
currentAuditLogs.stream().forEach(auditLog -> {
LOG.debug("Audit log to save: {}", auditLog);
});
if (tx.wasRolledBack()) {
if (tx.getStatus().equals(TransactionStatus.ROLLED_BACK)) {
LOG.warn("Transaction was rolled back. Audit logs likely won't be persisted");
}
this.auditTrailService.addAuditLogs(currentAuditLogs);
......@@ -773,9 +774,9 @@ public class AuditTrailInterceptor extends EmptyInterceptor implements Initializ
final long level = auditLogStack.get().size();
LOG.trace("afterTransactionCompletion transaction level={}", level);
if (tx.wasCommitted()) {
if (tx.getStatus().equals(TransactionStatus.COMMITTED)) {
LOG.trace("Transaction was committed, level={}", level);
} else if (tx.wasRolledBack()) {
} else if (tx.getStatus().equals(TransactionStatus.ROLLED_BACK)) {
LOG.trace("Transaction was rolled back, level={}", level);
}
......
......@@ -291,12 +291,12 @@ public class AuditTrailServiceTest extends ServiceTest {
other1 = otherEntityRepository.save(other1);
OtherEntity other2 = new OtherEntity("Other2");
other2 = otherEntityRepository.save(other2);
ExampleAuditedEntity entity = new ExampleAuditedEntity();
entity.setName("Test 1");
entity = exampleAuditedEntityService.save(entity);
assertThat(listAuditLogs(entity), hasSize(0));
entity.setOthers(Arrays.asList(other1));
entity = exampleAuditedEntityService.save(entity);
assertThat(listAuditLogs(entity), hasSize(1));
......
......@@ -37,7 +37,7 @@ import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate4.HibernateExceptionTranslator;
import org.springframework.orm.hibernate5.HibernateExceptionTranslator;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
......@@ -140,7 +140,7 @@ public class DatabaseConfig {
// LOG.trace("JPA: " + key + " = " + jpaProperties.get(key));
// }
jpaProperties.put("hibernate.ejb.interceptor", new EmptyInterceptor() {
jpaProperties.put("hibernate.session_factory.interceptor", new EmptyInterceptor() {
private static final long serialVersionUID = 412280557897728434L;
// NOTE We're using the auditTrailInterceptor() to fetch the lazy-initialized
......
......@@ -24,3 +24,4 @@ hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFa
hibernate.cache.use_structured_entries=false
hibernate.generate_statistics=false
hibernate.id.new_generator_mappings=false
......@@ -28,7 +28,7 @@ import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate4.HibernateExceptionTranslator;
import org.springframework.orm.hibernate5.HibernateExceptionTranslator;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
......
......@@ -40,17 +40,15 @@
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
<aspectj.version>1.7.2</aspectj.version>
<jackson.version>2.7.7</jackson.version>
<spring.version>4.3.2.RELEASE</spring.version>
<spring.data.version>1.10.4.RELEASE</spring.data.version>
<spring.security.oauth2.version>2.0.11.RELEASE</spring.security.oauth2.version>
<jackson.version>2.9.8</jackson.version>
<spring.version>4.3.22.RELEASE</spring.version>
<spring.data.version>1.11.18.RELEASE</spring.data.version>
<spring.security.oauth2.version>2.3.3.RELEASE</spring.security.oauth2.version>
<querydsl.version>4.1.4</querydsl.version>
<spring.security.version>4.1.3.RELEASE</spring.security.version>
<hibernate.version>4.3.11.Final</hibernate.version>
<hsqldb.version>2.4.0</hsqldb.version>
<spring.security.version>4.2.11.RELEASE</spring.security.version>
<hibernate.version>5.2.17.Final</hibernate.version>
<hsqldb.version>2.4.1</hsqldb.version>
<tomcat-jdbc.version>8.5.8</tomcat-jdbc.version>
<ehcache.version>2.7.4</ehcache.version>
</properties>
<repositories>
......@@ -185,7 +183,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
<scope>provided</scope>
</dependency>
......
......@@ -155,7 +155,7 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate4</artifactId>
<artifactId>jackson-datatype-hibernate5</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
......
......@@ -29,7 +29,7 @@ import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate4.HibernateExceptionTranslator;
import org.springframework.orm.hibernate5.HibernateExceptionTranslator;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
......
......@@ -20,7 +20,7 @@ import java.util.List;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import org.genesys.blocks.security.test.ServiceTest;
import org.junit.runner.RunWith;
......@@ -65,7 +65,7 @@ public abstract class AbstractRestTest extends ServiceTest {
final MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
final ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Hibernate4Module());
mapper.registerModule(new Hibernate5Module());
// serialization
mapper.disable(SerializationFeature.EAGER_SERIALIZER_FETCH);
// deserialization
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment