From 52d684d61118726772445319ab94a42c4b95f22b Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 26 Nov 2023 15:42:22 -0800 Subject: [PATCH] Fix JPA. --- wise-webapp/db/wisemapping.properties | 5 -- wise-webapp/db/wisemapping.script | 46 ------------------- .../com/wisemapping/config/Application.java | 2 - .../wisemapping/config/HibernateConfig.java | 4 +- .../com/wisemapping/dao/MindmapManager.java | 1 - .../wisemapping/dao/MindmapManagerImpl.java | 8 +++- .../src/main/resources/application.properties | 1 + 7 files changed, 11 insertions(+), 56 deletions(-) delete mode 100644 wise-webapp/db/wisemapping.properties delete mode 100644 wise-webapp/db/wisemapping.script diff --git a/wise-webapp/db/wisemapping.properties b/wise-webapp/db/wisemapping.properties deleted file mode 100644 index 69efbd3e..00000000 --- a/wise-webapp/db/wisemapping.properties +++ /dev/null @@ -1,5 +0,0 @@ -#HSQL Database Engine 2.7.1 -#Fri Nov 24 19:26:20 PST 2023 -modified=yes -tx_timestamp=458 -version=2.7.1 diff --git a/wise-webapp/db/wisemapping.script b/wise-webapp/db/wisemapping.script deleted file mode 100644 index 691beff2..00000000 --- a/wise-webapp/db/wisemapping.script +++ /dev/null @@ -1,46 +0,0 @@ -SET DATABASE UNIQUE NAME HSQLDB8C04588647 -SET DATABASE DEFAULT RESULT MEMORY ROWS 0 -SET DATABASE EVENT LOG LEVEL 0 -SET DATABASE TRANSACTION CONTROL LOCKS -SET DATABASE DEFAULT ISOLATION LEVEL READ COMMITTED -SET DATABASE TRANSACTION ROLLBACK ON CONFLICT TRUE -SET DATABASE TEXT TABLE DEFAULTS '' -SET DATABASE SQL NAMES FALSE -SET DATABASE SQL RESTRICT EXEC FALSE -SET DATABASE SQL REFERENCES FALSE -SET DATABASE SQL SIZE TRUE -SET DATABASE SQL TYPES FALSE -SET DATABASE SQL TDC DELETE TRUE -SET DATABASE SQL TDC UPDATE TRUE -SET DATABASE SQL SYS INDEX NAMES TRUE -SET DATABASE SQL CONCAT NULLS TRUE -SET DATABASE SQL UNIQUE NULLS TRUE -SET DATABASE SQL CONVERT TRUNCATE TRUE -SET DATABASE SQL AVG SCALE 0 -SET DATABASE SQL DOUBLE NAN TRUE -SET FILES WRITE DELAY 500 MILLIS -SET FILES BACKUP INCREMENT TRUE -SET FILES CACHE SIZE 10000 -SET FILES CACHE ROWS 50000 -SET FILES SCALE 32 -SET FILES LOB SCALE 32 -SET FILES DEFRAG 0 -SET FILES NIO TRUE -SET FILES NIO SIZE 256 -SET FILES LOG TRUE -SET FILES LOG SIZE 50 -SET FILES CHECK 458 -SET DATABASE COLLATION "SQL_TEXT" PAD SPACE -CREATE USER SA PASSWORD DIGEST 'd41d8cd98f00b204e9800998ecf8427e' -ALTER USER SA SET LOCAL TRUE -CREATE SCHEMA PUBLIC AUTHORIZATION DBA -ALTER SEQUENCE SYSTEM_LOBS.LOB_ID RESTART WITH 1 -SET DATABASE DEFAULT INITIAL SCHEMA PUBLIC -GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CARDINAL_NUMBER TO PUBLIC -GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.YES_OR_NO TO PUBLIC -GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CHARACTER_DATA TO PUBLIC -GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.SQL_IDENTIFIER TO PUBLIC -GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.TIME_STAMP TO PUBLIC -GRANT DBA TO SA -SET SCHEMA SYSTEM_LOBS -INSERT INTO BLOCKS VALUES(0,2147483647,0) diff --git a/wise-webapp/src/main/java/com/wisemapping/config/Application.java b/wise-webapp/src/main/java/com/wisemapping/config/Application.java index 76759277..c694c89a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/Application.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/Application.java @@ -16,9 +16,7 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; @EnableWebMvc -@Configuration @EnableTransactionManagement -@ComponentScan @SpringBootApplication @EnableJpaRepositories("com.wisemapping.model") @ImportResource("classpath:spring/wisemapping-common.xml") diff --git a/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java b/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java index 1caa213b..a4e19549 100644 --- a/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java +++ b/wise-webapp/src/main/java/com/wisemapping/config/HibernateConfig.java @@ -1,6 +1,9 @@ package com.wisemapping.config; +import jakarta.persistence.EntityManagerFactory; import org.apache.commons.dbcp2.BasicDataSource; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -14,7 +17,6 @@ import java.util.Properties; @Configuration @EnableTransactionManagement public class HibernateConfig { - // @Value("${database.hibernate.dialect}") // private String dbDialect; // diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java index 3bff94cc..f2a34259 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java @@ -22,7 +22,6 @@ import com.wisemapping.model.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.io.IOException; import java.util.List; public interface MindmapManager { diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java index 4892391c..adc8f841 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java @@ -20,6 +20,7 @@ package com.wisemapping.dao; import com.wisemapping.model.*; import jakarta.annotation.Resource; +import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaDelete; import jakarta.persistence.criteria.CriteriaQuery; @@ -29,6 +30,7 @@ import org.hibernate.SessionFactory; import org.hibernate.query.SelectionQuery; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import java.util.Calendar; @@ -37,7 +39,11 @@ import java.util.List; @Repository("mindmapManager") public class MindmapManagerImpl implements MindmapManager { - @Resource + + @Autowired + private EntityManagerFactory entityManagerFactory; + + @Autowired private SessionFactory sessionFactory; @Override diff --git a/wise-webapp/src/main/resources/application.properties b/wise-webapp/src/main/resources/application.properties index c787ae43..04a919e7 100755 --- a/wise-webapp/src/main/resources/application.properties +++ b/wise-webapp/src/main/resources/application.properties @@ -180,5 +180,6 @@ spring.jpa.open-in-view=true spring.h2.console.enabled=true spring.h2.console.path=/h2-ui +spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext