Skip to content

Commit 568ddec

Browse files
committed
Fixed errors when trying to use the Flyway Migration.
1 parent 5b45452 commit 568ddec

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>de.ree6</groupId>
88
<artifactId>Ree6-SQL</artifactId>
99
<description>This is the SQL-Module for Ree6!</description>
10-
<version>2.2.5</version>
10+
<version>2.2.6</version>
1111

1212
<properties>
1313
<sonar.organization>ree6-applications</sonar.organization>

src/main/java/de/presti/ree6/sql/DatabaseTyp.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,29 @@ public enum DatabaseTyp {
1313
/**
1414
* The MariaDB Database Information.
1515
*/
16-
MariaDB("jdbc:mariadb://%s:%s/%s", "org.hibernate.dialect.MariaDBDialect", "org.mariadb.jdbc.Driver",true),
16+
MariaDB("jdbc:mariadb://%s:%s/%s", "org.hibernate.dialect.MariaDBDialect", "org.mariadb.jdbc.Driver",
17+
"org.flywaydb.database.mysql.MySQLConnection", true),
1718

1819
/**
1920
* The SQLite Database Information.
2021
*/
21-
SQLite("jdbc:sqlite:%s", "org.hibernate.community.dialect.SQLiteDialect", "org.sqlite.JDBC", false),
22+
SQLite("jdbc:sqlite:%s", "org.hibernate.community.dialect.SQLiteDialect", "org.sqlite.JDBC", "", false),
2223

2324
/**
2425
* The PostgreSQL Database Information.
2526
*/
26-
PostgreSQL("jdbc:postgresql://%s:%s/%s", "org.hibernate.dialect.PostgreSQLDialect", "org.postgresql.Driver",true),
27+
PostgreSQL("jdbc:postgresql://%s:%s/%s", "org.hibernate.dialect.PostgreSQLDialect", "org.postgresql.Driver",
28+
"org.flywaydb.database.postgresql.PostgreSQLConnection", true),
2729

2830
/**
2931
* H2 Database Information.
3032
*/
31-
H2("jdbc:h2:%s;NON_KEYWORDS=VALUE,DAY,MONTH,YEAR;", "org.hibernate.dialect.H2Dialect", "org.h2.Driver",false),
33+
H2("jdbc:h2:%s;NON_KEYWORDS=VALUE,DAY,MONTH,YEAR;", "org.hibernate.dialect.H2Dialect", "org.h2.Driver", "",false),
3234

3335
/**
3436
* H2 Server Database Information.
3537
*/
36-
H2_Server("jdbc:h2:tcp://%s:%s/%s", "org.hibernate.dialect.H2Dialect", "org.h2.Driver",false);
38+
H2_Server("jdbc:h2:tcp://%s:%s/%s", "org.hibernate.dialect.H2Dialect", "org.h2.Driver", "",false);
3739

3840
/**
3941
* The JDBC Connection URL used by HikariCP and Hibernate.
@@ -50,6 +52,11 @@ public enum DatabaseTyp {
5052
*/
5153
private final String driverClass;
5254

55+
/**
56+
* The Flyway Class used for the Migration.
57+
*/
58+
private final String flywayClass;
59+
5360
/**
5461
* If the SQL-Typ requires an authentication.
5562
*/

src/main/java/de/presti/ree6/sql/SQLSession.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ public SQLSession(SQLConfig config) {
137137

138138
try {
139139
Class.forName(databaseTyp.getDriverClass());
140+
if (!databaseTyp.getFlywayClass().isBlank()) {
141+
Class.forName(databaseTyp.getFlywayClass());
142+
}
140143
} catch (ClassNotFoundException e) {
141144
// Somehow this fixes the Issue?
142145
log.warn("Couldn't load " + databaseTyp.name() + " Driver!\nThis could lead to errors!", e);

src/main/java/de/presti/ree6/sql/entities/Recording.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
import com.google.gson.JsonArray;
44
import com.google.gson.JsonElement;
5-
import de.presti.ree6.sql.converter.ByteToBlobAttributeConverter;
65
import de.presti.ree6.sql.converter.JsonToBlobAttributeConverter;
76
import jakarta.persistence.*;
7+
import org.hibernate.annotations.JdbcTypeCode;
88

99
import java.security.SecureRandom;
10+
import java.sql.Types;
1011
import java.util.Base64;
1112

1213
/**
@@ -44,8 +45,9 @@ public class Recording {
4445
/**
4546
* The WAV-File bytes.
4647
*/
47-
@Convert(converter = ByteToBlobAttributeConverter.class)
48-
@Column(name = "recording")
48+
@Lob
49+
@JdbcTypeCode(value = Types.BLOB)
50+
@Column(name = "recording", length = 157286400)
4951
byte[] recording;
5052

5153
/**

src/main/resources/sql/migrations/V8__Fixing-DataTyp.sql renamed to src/main/resources/sql/migrations/V8__Fix_Recording.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ ALTER TABLE Recording
22
DROP COLUMN recording;
33

44
ALTER TABLE Recording
5-
ADD recording BLOB NULL;
5+
ADD recording LONGBLOB NULL;

0 commit comments

Comments
 (0)