From 7724d9106d6c9fcb114d5cd3888d4184480c54e0 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 3 Feb 2024 19:37:10 -0800 Subject: [PATCH] Clean up jpa setting. --- wise-webapp/pom.xml | 12 +++-- .../config/common/CommonConfig.java | 2 +- .../config/common/HibernateConfig.java | 53 ------------------- .../wisemapping/config/common/JPAConfig.java | 16 ++++++ .../src/main/resources/application.properties | 36 +++++++------ 5 files changed, 44 insertions(+), 75 deletions(-) delete mode 100644 wise-webapp/src/main/java/com/wisemapping/config/common/HibernateConfig.java create mode 100644 wise-webapp/src/main/java/com/wisemapping/config/common/JPAConfig.java diff --git a/wise-webapp/pom.xml b/wise-webapp/pom.xml index 5cd001bf..7501fe88 100644 --- a/wise-webapp/pom.xml +++ b/wise-webapp/pom.xml @@ -131,11 +131,6 @@ mysql-connector-j 8.1.0 - - org.apache.commons - commons-dbcp2 - 2.9.0 - org.eclipse.angus jakarta.mail @@ -153,6 +148,13 @@ 1.7 + + + com.zaxxer + HikariCP + 5.1.0 + + org.hsqldb diff --git a/wise-webapp/src/main/java/com/wisemapping/config/common/CommonConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/common/CommonConfig.java index e3070009..52d113cb 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/common/CommonConfig.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/common/CommonConfig.java @@ -10,7 +10,7 @@ import org.springframework.context.annotation.Import; import org.springframework.context.annotation.ImportResource; @ComponentScan(basePackageClasses = {AuthenticationProvider.class, MindmapServiceImpl.class, LabelManagerImpl.class, VelocityEngineUtils.class}) -@Import({HibernateConfig.class, SecurityConfig.class}) +@Import({JPAConfig.class, SecurityConfig.class}) @EnableAutoConfiguration @ImportResource(value = {"classpath:spring/wisemapping-mail.xml"}) public class CommonConfig { diff --git a/wise-webapp/src/main/java/com/wisemapping/config/common/HibernateConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/common/HibernateConfig.java deleted file mode 100644 index 98a15eb3..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/config/common/HibernateConfig.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.wisemapping.config.common; - -import com.wisemapping.dao.MindmapManagerImpl; -import com.wisemapping.model.User; -import com.wisemapping.service.MindmapServiceImpl; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; - - -@Configuration -@EnableJpaRepositories(basePackageClasses={MindmapServiceImpl.class, MindmapManagerImpl.class}) -@EntityScan(basePackageClasses= User.class) -public class HibernateConfig { - -// @Bean -// public HibernateTransactionManager hibernateTransactionManager() { -// final HibernateTransactionManager result = new HibernateTransactionManager(); -// result.setNestedTransactionAllowed(true); -// // @Todo: Am I creatting two instances ??? -// result.setSessionFactory(sessionFactory().getObject()); -// return result; -// } -// -// private Properties hibernateProperties() { -// final Properties result = new Properties(); -// result.setProperty("hibernate.dialect", dbDialect); -// result.setProperty("hibernate.default_batch_fetch_size", "200"); -// result.setProperty("hibernate.nestedTransactionAllowed", "true"); -// result.setProperty("hibernate.auto_quote_keyword", "true"); -// -// return result; -// } -// -// @Bean -// public DataSource dataSource() { -// final BasicDataSource result = new BasicDataSource(); -// result.setDriverClassName(dbDriver); -// result.setUrl(dbUrl); -// result.setUsername(dbUsername); -// result.setPassword(dbPassword); -// result.setTestOnBorrow(dbSetOnBorrow); -// -// result.setDefaultQueryTimeout(15); -// result.setMaxTotal(100); -// result.setMaxIdle(30); -// result.setInitialSize(5); -// result.setMaxWaitMillis(10000); -// result.setValidationQuery(dbValQuery); -// -// return result; -// } -} diff --git a/wise-webapp/src/main/java/com/wisemapping/config/common/JPAConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/common/JPAConfig.java new file mode 100644 index 00000000..9f68abdc --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/config/common/JPAConfig.java @@ -0,0 +1,16 @@ +package com.wisemapping.config.common; + +import com.wisemapping.dao.MindmapManagerImpl; +import com.wisemapping.model.User; +import com.wisemapping.service.MindmapServiceImpl; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + + +@Configuration +@EnableJpaRepositories(basePackageClasses={MindmapServiceImpl.class, MindmapManagerImpl.class}) +@EntityScan(basePackageClasses= User.class) +public class JPAConfig { + +} diff --git a/wise-webapp/src/main/resources/application.properties b/wise-webapp/src/main/resources/application.properties index eb6b13ec..5bdf50c0 100755 --- a/wise-webapp/src/main/resources/application.properties +++ b/wise-webapp/src/main/resources/application.properties @@ -1,5 +1,5 @@ ################################################################################## -SpringBoot Common +SpringBoot DataSource ################################################################################## # JPA @@ -11,9 +11,22 @@ spring.jpa.properties.hibernate.format_sql=true spring.sql.init.mode=always spring.sql.init.platform=hsqldb -# LOG -logging.level.root=INFO -logging.level.org.apache.tomcat=INFO +spring.jpa.properties.hibernate.default_batch_fetch_size=200 +#spring.jpa.properties.hibernate.auto_quote_keyword=true + + +# Connection pool (https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#application-properties.data.spring.datasource.hikari) +#spring.datasource.hikari.connection-test-query= +#spring.datasource.hikari.connection-timeout= + +# Embed Datasource Configuration +database.base.url=/Users/veigap/ +spring.datasource.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping +spring.datasource.username=sa +spring.datasource.password= + +spring.datasource.driver-class-name = org.hsqldb.jdbc.JDBCDriver +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect ################################################################################## # Mail configuration. Must be configured to enable user registration confirmation. @@ -119,15 +132,6 @@ security.oauth2.google.url=https//review #accounts.exclusion.domain= -################################################################################## -# Database Configuration -################################################################################## - - -database.base.url=/Users/veigap/ -spring.datasource.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping -spring.datasource.username=sa -spring.datasource.password= - -spring.datasource.driver-class-name = org.hsqldb.jdbc.JDBCDriver -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect +# LOG +logging.level.root=INFO +logging.level.org.apache.tomcat=INFO