From fb27830304cb32d2437b8669199b1e41cf858576 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Fri, 28 Feb 2025 14:22:54 +1100 Subject: [PATCH] fix: use @SQLDatasource declaration --- .../main/java/xyz/block/ftl/SQLDatasource.java | 3 +-- jvm-runtime/jvm_hot_reload_test.go | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/jvm-runtime/ftl-runtime/common/runtime/src/main/java/xyz/block/ftl/SQLDatasource.java b/jvm-runtime/ftl-runtime/common/runtime/src/main/java/xyz/block/ftl/SQLDatasource.java index 468dceb0f7..b621d2ff00 100644 --- a/jvm-runtime/ftl-runtime/common/runtime/src/main/java/xyz/block/ftl/SQLDatasource.java +++ b/jvm-runtime/ftl-runtime/common/runtime/src/main/java/xyz/block/ftl/SQLDatasource.java @@ -8,8 +8,7 @@ /** * Annotation to specify a SQL datasource. * - * This can be added anywhere in your application, but it is recommended to add it to a package-info.java file - * at the root of your package hierarchy. + * This can be added anywhere in your application. * */ @Retention(RetentionPolicy.RUNTIME) diff --git a/jvm-runtime/jvm_hot_reload_test.go b/jvm-runtime/jvm_hot_reload_test.go index cb0895e959..8018648910 100644 --- a/jvm-runtime/jvm_hot_reload_test.go +++ b/jvm-runtime/jvm_hot_reload_test.go @@ -97,14 +97,13 @@ func TestLifecycleJVM(t *testing.T) { in.Call("echo", "hello", map[string]string{"name": "Bob"}, func(t testing.TB, response map[string]string) { assert.Equal(t, "Bye, Bob!", response["message"]) }), - // Now lets add a database, add the ftl config - in.EditFile("echo", func(content []byte) []byte { - return []byte(` -quarkus.datasource.testdb.db-kind=postgresql -quarkus.hibernate-orm.datasource=testdb -`) - }, "src/main/resources/application.properties"), - + // Now lets add the DB + in.IfLanguage("java", in.EditFile("echo", func(content []byte) []byte { + return []byte(strings.ReplaceAll(string(content), "@Export", "@Export\n\n@SQLDatasource(name = \"testdb\", type = SQLDatabaseType.POSTGRESQL)")) + }, "src/main/java/ftl/echo/Echo.java")), + in.IfLanguage("kotlin", in.EditFile("echo", func(content []byte) []byte { + return []byte(strings.ReplaceAll(string(content), "@Export", "@Export\n\n@SQLDatasource(name = \"testdb\", type = SQLDatabaseType.POSTGRESQL)")) + }, "src/main/kotlin/ftl/echo/Echo.kt")), // Create a new datasource in.Exec("ftl", "postgres", "new", "echo.testdb"),