Resolving Sqlite3 + Hibernate issues; rename and cleaned up files

This commit is contained in:
itdominator 2023-09-20 21:10:36 -05:00
parent 0ef5294796
commit e0921074fa
10 changed files with 47 additions and 58 deletions

View File

@ -11,6 +11,6 @@ function main() {
cd "$(dirname "")" cd "$(dirname "")"
echo "Working Dir: " $(pwd) echo "Working Dir: " $(pwd)
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk/" 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 "$@"; main "$@";

58
pom.xml
View File

@ -17,8 +17,11 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version> <java.version>17</java.version>
<vaadin.version>24.1.7</vaadin.version> <spring.version>6.0.11</spring.version>
<sqlite-jdbc.version>3.25.2</sqlite-jdbc.version> <!-- <spring.version>5.3.2</spring.version> -->
<hibernate.version>6.3.1.Final</hibernate.version>
<!-- <hibernate.version>5.6.9.Final</hibernate.version> -->
<sqlite-jdbc.version>3.30.1</sqlite-jdbc.version>
</properties> </properties>
<dependencies> <dependencies>
@ -26,18 +29,9 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<!-- <dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId> <artifactId>spring-jdbc</artifactId>
<version>6.0.11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
@ -46,26 +40,36 @@
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId> <artifactId>spring-beans</artifactId>
<version>6.0.11</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-community-dialects</artifactId>
<version>6.1.6.Final</version>
</dependency>
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>${sqlite-jdbc.version}</version> <version>${sqlite-jdbc.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-community-dialects</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency> <dependency>
<groupId>jakarta.validation</groupId> <groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId> <artifactId>jakarta.validation-api</artifactId>
@ -86,13 +90,6 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<!-- <dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency> -->
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -122,21 +119,6 @@
<target>17</target> <target>17</target>
<executable>/usr/lib/jvm/java-17-openjdk/bin/javac</executable> <executable>/usr/lib/jvm/java-17-openjdk/bin/javac</executable>
</configuration> </configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<id>frontend</id>
<phase>compile</phase>
<goals>
<goal>prepare-frontend</goal>
<goal>build-frontend</goal>
</goals>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -2,8 +2,11 @@ package com.itdominator.api;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
@SpringBootApplication @SpringBootApplication
@Configuration
public class ThumbnailApiApplication { public class ThumbnailApiApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -45,11 +45,11 @@ public class ThumbnailerApiController {
} }
@PreAuthorize("hashPermission('User')") @PreAuthorize("hashPermission('User')")
@PostMapping("/get-thumbnail/hash/{hash}") @PostMapping("/get-thumbnail/hash/{fileHash}")
public ThumbnailDto getThumbnailByHash( 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);
} }

View File

@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
@Entity @Entity
@Table(name = "thumbnails") @Table
@Data @Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true) @EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class Thumbnails implements Serializable { public class Thumbnails implements Serializable {

View File

@ -8,7 +8,6 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.itdominator.api.dto.ThumbnailDto; import com.itdominator.api.dto.ThumbnailDto;
import com.itdominator.api.entities.Thumbnails; import com.itdominator.api.entities.Thumbnails;
import com.itdominator.api.entities.ThumbnailsId; import com.itdominator.api.entities.ThumbnailsId;
@ -20,9 +19,9 @@ public interface ThumbnailRepository extends JpaRepository<Thumbnails, Thumbnail
@Query(value = "SELECT * FROM thumbnails", nativeQuery = true) @Query(value = "SELECT * FROM thumbnails", nativeQuery = true)
List<ThumbnailDto> getAllThumbnails(); List<ThumbnailDto> getAllThumbnails();
@Query(value = "SELECT path FROM thumbnails WHERE hash = :hash", nativeQuery = true) @Query(value = "SELECT path FROM thumbnails WHERE file_hash = :fileHash", nativeQuery = true)
ThumbnailDto findThumbnailByHash(String id); 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); ThumbnailDto findThumbnailById(int id);
} }

View File

@ -28,8 +28,8 @@ public class ThumbnailerService {
} }
public ThumbnailDto getThumbnailByHash(final String hash) { public ThumbnailDto getThumbnailByHash(final String fileHash) {
return thumbnailRepository.findThumbnailByHash(hash); return thumbnailRepository.findThumbnailByHash(fileHash);
} }
public ThumbnailDto getThumbnailByIdOrHashQuery(final ThumbnailSearchCriteria criteria) { public ThumbnailDto getThumbnailByIdOrHashQuery(final ThumbnailSearchCriteria criteria) {

View File

@ -1,14 +1,19 @@
server.port=8999 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 driverClassName=org.sqlite.JDBC
spring.jpa.properties.hibernate.dialect=org.hibernate.community.dialect.SQLiteDialect
spring.jpa.database-platform=org.hibernate.community.dialect.SQLiteDialect spring.jpa.database-platform=org.hibernate.community.dialect.SQLiteDialect
#url=jdbc:sqlite:memory:myDb?cache=shared #url=jdbc:sqlite:memory:myDb?cache=shared
url=jdbc:sqlite:src/main/resource/static/db/database.db?cache=shared url=jdbc:sqlite:src/main/resources/static/db/database.db
username=
password=
hibernate.hbm2ddl.auto=create-drop hibernate.hbm2ddl.auto=create-drop
hibernate.show_sql=true 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

View File

@ -12,6 +12,6 @@ function main() {
echo "Working Dir: " $(pwd) echo "Working Dir: " $(pwd)
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk/" 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 "$@"; main "$@";