From e0921074fa7ef6cd10e2c19b9be2ef89357d1356 Mon Sep 17 00:00:00 2001
From: itdominator <1itdominator@gmail.com>
Date: Wed, 20 Sep 2023 21:10:36 -0500
Subject: [PATCH] Resolving Sqlite3 + Hibernate issues; rename and cleaned up
files
---
build.sh | 2 +-
pom.xml | 58 ++++++------------
.../api/ThumbnailApiApplication.java | 3 +
.../controller/ThumbnailerApiController.java | 6 +-
.../itdominator/api/entities/Thumbnails.java | 2 +-
.../api/repositories/ThumbnailRepository.java | 7 +--
.../api/services/ThumbnailerService.java | 4 +-
src/main/resources/application.properties | 21 ++++---
src/main/resources/static/db/database.db | Bin 16384 -> 16384 bytes
start-app.sh | 2 +-
10 files changed, 47 insertions(+), 58 deletions(-)
diff --git a/build.sh b/build.sh
index d206791..1924d20 100644
--- a/build.sh
+++ b/build.sh
@@ -11,6 +11,6 @@ function main() {
cd "$(dirname "")"
echo "Working Dir: " $(pwd)
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk/"
- mvn clean package -Pproduction -Dmaven.test.skip=true
+ mvn clean package -U -Pproduction -Dmaven.test.skip=true
}
main "$@";
diff --git a/pom.xml b/pom.xml
index 8e2bca8..47b140f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,8 +17,11 @@
UTF-8
17
- 24.1.7
- 3.25.2
+ 6.0.11
+
+ 6.3.1.Final
+
+ 3.30.1
@@ -26,18 +29,9 @@
org.springframework.boot
spring-boot-starter-security
-
-
- org.springframework.session
- spring-session-core
-
org.springframework
spring-jdbc
- 6.0.11
org.springframework.data
@@ -46,26 +40,36 @@
org.springframework
spring-beans
- 6.0.11
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
com.h2database
h2
runtime
+
+ org.hibernate.orm
+ hibernate-community-dialects
+ 6.1.6.Final
+
org.xerial
sqlite-jdbc
${sqlite-jdbc.version}
-
- org.hibernate.orm
- hibernate-community-dialects
-
org.projectlombok
lombok
+
+ jakarta.persistence
+ jakarta.persistence-api
+ 3.1.0
+
jakarta.validation
jakarta.validation-api
@@ -86,13 +90,6 @@
-
@@ -123,21 +120,6 @@
/usr/lib/jvm/java-17-openjdk/bin/javac
-
- com.vaadin
- vaadin-maven-plugin
- ${vaadin.version}
-
-
- frontend
- compile
-
- prepare-frontend
- build-frontend
-
-
-
-
diff --git a/src/main/java/com/itdominator/api/ThumbnailApiApplication.java b/src/main/java/com/itdominator/api/ThumbnailApiApplication.java
index ba0d901..013d9fa 100644
--- a/src/main/java/com/itdominator/api/ThumbnailApiApplication.java
+++ b/src/main/java/com/itdominator/api/ThumbnailApiApplication.java
@@ -2,8 +2,11 @@ package com.itdominator.api;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Configuration;
+
@SpringBootApplication
+@Configuration
public class ThumbnailApiApplication {
public static void main(String[] args) {
diff --git a/src/main/java/com/itdominator/api/controller/ThumbnailerApiController.java b/src/main/java/com/itdominator/api/controller/ThumbnailerApiController.java
index f8adeb3..c4e105a 100644
--- a/src/main/java/com/itdominator/api/controller/ThumbnailerApiController.java
+++ b/src/main/java/com/itdominator/api/controller/ThumbnailerApiController.java
@@ -45,11 +45,11 @@ public class ThumbnailerApiController {
}
@PreAuthorize("hashPermission('User')")
- @PostMapping("/get-thumbnail/hash/{hash}")
+ @PostMapping("/get-thumbnail/hash/{fileHash}")
public ThumbnailDto getThumbnailByHash(
- @Pattern(regexp = "[a-zA-Z0-9]{32}*$") @PathVariable("hash") final String hash
+ @Pattern(regexp = "[a-zA-Z0-9]{32}*$") @PathVariable("fileHash") final String fileHash
) {
- return thumbnailerService.getThumbnailByHash(hash);
+ return thumbnailerService.getThumbnailByHash(fileHash);
}
diff --git a/src/main/java/com/itdominator/api/entities/Thumbnails.java b/src/main/java/com/itdominator/api/entities/Thumbnails.java
index 9f390ef..e15062d 100644
--- a/src/main/java/com/itdominator/api/entities/Thumbnails.java
+++ b/src/main/java/com/itdominator/api/entities/Thumbnails.java
@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
@Entity
-@Table(name = "thumbnails")
+@Table
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class Thumbnails implements Serializable {
diff --git a/src/main/java/com/itdominator/api/repositories/ThumbnailRepository.java b/src/main/java/com/itdominator/api/repositories/ThumbnailRepository.java
index e6d3e62..1160700 100644
--- a/src/main/java/com/itdominator/api/repositories/ThumbnailRepository.java
+++ b/src/main/java/com/itdominator/api/repositories/ThumbnailRepository.java
@@ -8,7 +8,6 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.itdominator.api.dto.ThumbnailDto;
-
import com.itdominator.api.entities.Thumbnails;
import com.itdominator.api.entities.ThumbnailsId;
@@ -20,9 +19,9 @@ public interface ThumbnailRepository extends JpaRepository getAllThumbnails();
- @Query(value = "SELECT path FROM thumbnails WHERE hash = :hash", nativeQuery = true)
- ThumbnailDto findThumbnailByHash(String id);
+ @Query(value = "SELECT path FROM thumbnails WHERE file_hash = :fileHash", nativeQuery = true)
+ ThumbnailDto findThumbnailByHash(String fileHash);
- @Query(value = "SELECT path FROM thumbnails WHERE hashid = :id", nativeQuery = true)
+ @Query(value = "SELECT path FROM thumbnails WHERE id = :id", nativeQuery = true)
ThumbnailDto findThumbnailById(int id);
}
diff --git a/src/main/java/com/itdominator/api/services/ThumbnailerService.java b/src/main/java/com/itdominator/api/services/ThumbnailerService.java
index 3018727..0ee5842 100644
--- a/src/main/java/com/itdominator/api/services/ThumbnailerService.java
+++ b/src/main/java/com/itdominator/api/services/ThumbnailerService.java
@@ -28,8 +28,8 @@ public class ThumbnailerService {
}
- public ThumbnailDto getThumbnailByHash(final String hash) {
- return thumbnailRepository.findThumbnailByHash(hash);
+ public ThumbnailDto getThumbnailByHash(final String fileHash) {
+ return thumbnailRepository.findThumbnailByHash(fileHash);
}
public ThumbnailDto getThumbnailByIdOrHashQuery(final ThumbnailSearchCriteria criteria) {
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 445259a..24b7eb3 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,14 +1,19 @@
server.port=8999
+spring.security.user.name=root
+spring.security.user.password=toor
+spring.security.user.roles=USER
+
+spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringJtaSessionContext
+
driverClassName=org.sqlite.JDBC
-spring.jpa.database-platform=org.hibernate.community.dialect.SQLiteDialect
-#url=jdbc:sqlite:memory:myDb?cache=shared
-url=jdbc:sqlite:src/main/resource/static/db/database.db?cache=shared
-username=
-password=
+spring.jpa.properties.hibernate.dialect=org.hibernate.community.dialect.SQLiteDialect
+spring.jpa.database-platform=org.hibernate.community.dialect.SQLiteDialect
+#url=jdbc:sqlite:memory:myDb?cache=shared
+url=jdbc:sqlite:src/main/resources/static/db/database.db
hibernate.hbm2ddl.auto=create-drop
hibernate.show_sql=true
+spring.jpa.hibernate.ddl-auto=update
+
+
-spring.security.user.name=root
-spring.security.user.password=password
-spring.security.user.roles=USER
diff --git a/src/main/resources/static/db/database.db b/src/main/resources/static/db/database.db
index 326b2a98d739146f6d9a0cd933e2a604b4294509..62cd3a2752fb2a6ac5f7621feb704f35a494e72b 100644
GIT binary patch
delta 388
zcmZo@U~Fh$oFFa8%)r3F0>m)DJW%_45o2b=3h%r)B1(#)Irr;tX+(07^rZz~wR$i!-puW#%TP1NAuh_&dS$
zX!`&)1q6BeItE25c)Lbwfb3Rq3=Q%3^aDE5*VQjXlS|W>iA~&Haq=2|2{D9I;|&q)
N&ENSs6&48y003=8aU1{u
delta 352
zcmZo@U~Fh$oFFa8$iTqB0>m)DI8nz~n2|v*UWS+d2Lm(T4F1{WuY&P&WqRS0toa`tcx
zQt;!Mp=%*??mQ;=9(T%KQ)f<>~Pi!(Dt!P76q)!h}Ly*eN-}yNe7AXh-0HmT~WB>pF
diff --git a/start-app.sh b/start-app.sh
index 22fd168..0447701 100644
--- a/start-app.sh
+++ b/start-app.sh
@@ -12,6 +12,6 @@ function main() {
echo "Working Dir: " $(pwd)
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk/"
- /usr/lib/jvm/java-17-openjdk/bin/java -jar ./target/itdominator-0.0.1-SNAPSHOT.jar
+ /usr/lib/jvm/java-17-openjdk/bin/java -jar ./target/thumbnailer-api-0.0.1-SNAPSHOT.jar
}
main "$@";