ORMLite to JDBI

This commit is contained in:
2026-05-28 16:19:20 -04:00
parent 8b2ca5e072
commit 607595e3c2
25 changed files with 290 additions and 434 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
}
dependencies {
compileOnlyApi("com.j256.ormlite:ormlite-core:6.1")
compileOnlyApi("org.jdbi:jdbi3-core:3.53.0")
api("com.google.code.gson:gson:2.13.2")
compileOnly("io.papermc.paper:paper-api:26.1.2.build.+")
@@ -1,22 +0,0 @@
package dev.plex.api.storage;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
/**
* Creates ORMLite DAOs for module-scoped tables.
*/
public interface ModuleOrm
{
/**
* Creates or returns a cached DAO for a module-local table.
*
* @param entityClass ORMLite entity class
* @param localTableName module-local table name
* @param <T> entity type
* @param <ID> entity ID type
* @return ORMLite DAO using the module-prefixed physical table
* @throws SQLException if the DAO cannot be created
*/
<T, ID> Dao<T, ID> dao(Class<T> entityClass, String localTableName) throws SQLException;
}
@@ -1,6 +1,6 @@
package dev.plex.api.storage;
import java.sql.SQLException;
import org.jdbi.v3.core.Jdbi;
/**
* Module-scoped storage namespace.
@@ -30,19 +30,10 @@ public interface ModuleStorage
ModuleMigrations migrations();
/**
* Returns module ORMLite DAO operations.
* Returns the shared JDBI instance. Build SQL with {@link #table(String)} for
* physical-table resolution; use {@code jdbi().inTransaction(...)} for multi-statement transactions.
*
* @return module ORMLite DAO operations
* @return shared JDBI instance
*/
ModuleOrm orm();
/**
* Runs work inside a storage transaction.
*
* @param callable work to run
* @param <T> callback result type
* @return callback result
* @throws SQLException if the transaction cannot complete
*/
<T> T transaction(SqlCallable<T> callable) throws SQLException;
Jdbi jdbi();
}
@@ -1,20 +0,0 @@
package dev.plex.api.storage;
import java.sql.SQLException;
/**
* Callback used for SQL work that does not receive a connection directly.
*
* @param <T> callback result type
*/
@FunctionalInterface
public interface SqlCallable<T>
{
/**
* Runs SQL work.
*
* @return callback result
* @throws SQLException if the SQL work cannot complete
*/
T call() throws SQLException;
}