Commit ac270434 authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza

Hibernate 5

- change default setting: hibernate.id.new_generator_mappings=false
- update hibernate version and hibernate settings
parent 108ec5b7
......@@ -70,17 +70,17 @@
<servlet-api.version>2.5</servlet-api.version>
<jsp-api.version>2.1</jsp-api.version>
<spring.framework.version>4.3.18.RELEASE</spring.framework.version>
<spring-data-jpa.version>1.11.13.RELEASE</spring-data-jpa.version>
<spring.framework.version>4.3.22.RELEASE</spring.framework.version>
<spring-data-jpa.version>1.11.18.RELEASE</spring-data-jpa.version>
<spring.security.version>4.1.5.RELEASE</spring.security.version>
<spring.security.oauth2.version>2.3.3.RELEASE</spring.security.oauth2.version>
<spring-security-jwt>1.0.8.RELEASE</spring-security-jwt>
<org.springframework.social-version>1.1.4.RELEASE</org.springframework.social-version>
<querydsl.version>4.1.4</querydsl.version>
<hibernate.version>4.3.11.Final</hibernate.version>
<hibernate.version>5.2.11.Final</hibernate.version>
<hibernate.validator.version>5.2.5.Final</hibernate.validator.version>
<hsqldb.version>2.3.6</hsqldb.version>
<hsqldb.version>2.4.1</hsqldb.version>
<ehcache.version>2.7.4</ehcache.version>
<slf4j.version>1.7.25</slf4j.version>
......@@ -235,7 +235,7 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate4</artifactId>
<artifactId>jackson-datatype-hibernate5</artifactId>
<version>2.9.9-SNAPSHOT</version>
</dependency>
......@@ -352,7 +352,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
......@@ -430,8 +430,8 @@
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-hibernate4</artifactId>
<version>${hazelcast.version}</version>
<artifactId>hazelcast-hibernate52</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
......@@ -528,7 +528,7 @@
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate4</artifactId>
<artifactId>liquibase-hibernate5</artifactId>
<version>${liquibase.version}</version>
<exclusions>
<exclusion>
......@@ -898,7 +898,7 @@
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate4</artifactId>
<artifactId>liquibase-hibernate5</artifactId>
<version>3.6</version>
</dependency>
<dependency>
......
......@@ -35,7 +35,7 @@ public interface Taxonomy2Repository extends JpaRepository<Taxonomy2, Long> {
@Query("select distinct t.genus from Taxonomy2 t join t.cropTaxonomies ct where t.genus like ?1 and ct.crop = ?2")
List<String> autocompleteGenusByCrop(String term, Crop crop, Pageable page);
@Query("select distinct t.species from Taxonomy2 t where t.species like ?1)")
@Query("select distinct t.species from Taxonomy2 t where t.species like ?1")
List<String> autocompleteSpecies(String term, Pageable page);
@Query("select distinct t.species from Taxonomy2 t join t.cropTaxonomies ct where t.species like ?1 and ct.crop = ?2")
......@@ -44,10 +44,10 @@ public interface Taxonomy2Repository extends JpaRepository<Taxonomy2, Long> {
@Query("select distinct t.species from Taxonomy2 t where t.species like ?1 and t.genus in (?2)")
List<String> autocompleteSpeciesByGenus(String term, List<String> genus, Pageable page);
@Query("select distinct t.taxonName from Taxonomy2 t where t.taxonName like ?1)")
@Query("select distinct t.taxonName from Taxonomy2 t where t.taxonName like ?1")
List<String> autocompleteTaxonomy(String term, Pageable page);
@Query("select distinct t.subtaxa from Taxonomy2 t where t.subtaxa like ?1)")
@Query("select distinct t.subtaxa from Taxonomy2 t where t.subtaxa like ?1")
List<String> autocompleteSubtaxa(String string, Pageable page);
@Query("select distinct t.subtaxa from Taxonomy2 t join t.cropTaxonomies ct where t.subtaxa like ?1 and ct.crop = ?2")
......
......@@ -15,7 +15,7 @@
*/
package org.genesys2.spring.config;
import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.oauth.model.OAuthClient;
......
......@@ -167,7 +167,7 @@ public class DatabaseConfig {
System.err.println("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
......
......@@ -54,8 +54,8 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module;
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module.Feature;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module.Feature;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.ILock;
import com.hazelcast.core.IQueue;
......@@ -196,7 +196,7 @@ public class ElasticsearchConfig {
public GenesysEntityMapper() {
mapper = new ObjectMapper();
Hibernate4Module hibernateModule = new Hibernate4Module();
Hibernate5Module hibernateModule = new Hibernate5Module();
hibernateModule.enable(Feature.FORCE_LAZY_LOADING);
hibernateModule.enable(Feature.SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS);
hibernateModule.enable(Feature.WRITE_MISSING_ENTITIES_AS_NULL);
......
......@@ -61,8 +61,8 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module;
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module.Feature;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module.Feature;
/**
* Spring MVC
......@@ -217,7 +217,7 @@ public class WebConfiguration extends WebMvcConfigurerAdapter {
final ObjectMapper mapper = new ObjectMapper();
Hibernate4Module hibernateModule = new Hibernate4Module();
Hibernate5Module hibernateModule = new Hibernate5Module();
hibernateModule.disable(Feature.FORCE_LAZY_LOADING);
hibernateModule.disable(Feature.SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS);
mapper.registerModule(hibernateModule);
......
......@@ -18,6 +18,7 @@ package org.genesys2.spring.hazelcast;
import java.util.Properties;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.CollectionRegion;
......@@ -27,7 +28,6 @@ import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.Settings;
import org.springframework.stereotype.Component;
import com.hazelcast.hibernate.HazelcastCacheRegionFactory;
......@@ -59,8 +59,8 @@ public class HazelcastCacheRegionFactoryWrapper implements RegionFactory {
}
@Override
public void start(Settings settings, Properties properties) throws CacheException {
hazelcastCacheRegionFactory.start(settings, properties);
public void start(SessionFactoryOptions sessionFactoryOptions, Properties properties) throws CacheException {
hazelcastCacheRegionFactory.start(sessionFactoryOptions, properties);
}
@Override
......
......@@ -17,3 +17,5 @@ hibernate.cache.region_prefix=hibernate
hibernate.cache.region.factory_class=org.genesys2.spring.hazelcast.HazelcastCacheRegionFactoryWrapper
hibernate.cache.use_structured_entries=false
hibernate.generate_statistics=false
hibernate.id.new_generator_mappings=false
hibernate.discriminator.ignore_explicit_for_joined=true
......@@ -53,8 +53,8 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module;
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module.Feature;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module.Feature;
public final class ApplicationConfig {
......@@ -235,12 +235,12 @@ public final class ApplicationConfig {
final MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
final ObjectMapper mapper = new ObjectMapper();
Hibernate4Module hibernateModule = new Hibernate4Module();
Hibernate5Module hibernateModule = new Hibernate5Module();
hibernateModule.disable(Feature.FORCE_LAZY_LOADING);
hibernateModule.disable(Feature.SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS);
mapper.registerModule(hibernateModule);
// serialization
mapper.disable(SerializationFeature.EAGER_SERIALIZER_FETCH);
// deserialization
......
......@@ -14,3 +14,5 @@ hibernate.cache.region_prefix=hibernate
#hibernate.cache.region.factory_class=org.hibernate.testing.cache.CachingRegionFactory
hibernate.cache.use_structured_entries=true
hibernate.generate_statistics=false
hibernate.id.new_generator_mappings=false
hibernate.discriminator.ignore_explicit_for_joined=true
\ No newline at end of file
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