-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to use Spring JdbcTemplate, with multi-language examples. #2494
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
236d47f
Document how to use Spring JdbcTemplate, with multi-language examples.
wetted ef552f8
Fix kotlin, groovification and a couple more assertions
timyates 3efd236
Unify whitespace and add doc tag
timyates 7463eef
Improve docs
wetted d4c04ac
Add documentation about setting the Spring Jdbc TX mgr for JdbcTemplate
wetted e20e061
Correct doc for property to kebob case
wetted 0f7096c
use transaction-manager in lower kebap case
sdelamo 9445f15
Merge branch 'master' into spring-jdbctemplate-docs
sdelamo 8f33c2c
remove ====
sdelamo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
doc-examples/jdbc-spring-template-example-groovy/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
plugins { | ||
id "groovy" | ||
id "io.micronaut.build.internal.data-example" | ||
} | ||
|
||
micronaut { | ||
version libs.versions.micronaut.platform.get() | ||
runtime "netty" | ||
testRuntime "spock" | ||
} | ||
|
||
dependencies { | ||
compileOnly projects.micronautDataProcessor | ||
compileOnly mnValidation.micronaut.validation.processor | ||
|
||
implementation projects.micronautDataJdbc | ||
implementation projects.micronautDataSpringJdbc | ||
implementation mnValidation.micronaut.validation | ||
|
||
runtimeOnly mnSql.micronaut.jdbc.tomcat | ||
runtimeOnly mnLogging.logback.classic | ||
runtimeOnly mnSql.h2 | ||
} |
1 change: 1 addition & 0 deletions
1
doc-examples/jdbc-spring-template-example-groovy/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
skipDocumentation=true |
33 changes: 33 additions & 0 deletions
33
...jdbc-spring-template-example-groovy/src/main/groovy/example/AbstractBookRepository.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package example | ||
|
||
import io.micronaut.context.annotation.Requires | ||
import io.micronaut.core.annotation.NonNull | ||
import io.micronaut.data.connection.jdbc.advice.DelegatingDataSource | ||
import io.micronaut.data.jdbc.annotation.JdbcRepository | ||
import io.micronaut.data.model.query.builder.sql.Dialect | ||
import io.micronaut.data.repository.CrudRepository | ||
import jakarta.transaction.Transactional | ||
import jakarta.validation.Valid | ||
import jakarta.validation.constraints.NotNull | ||
import org.springframework.jdbc.core.JdbcTemplate | ||
|
||
import javax.sql.DataSource | ||
|
||
@Requires(property = 'spec.name', value = 'BookRepositorySpec') | ||
// tag::clazz[] | ||
@JdbcRepository(dialect = Dialect.H2) | ||
abstract class AbstractBookRepository implements CrudRepository<@Valid Book, @NotNull Long> { | ||
|
||
private final JdbcTemplate jdbcTemplate; //<2> | ||
|
||
AbstractBookRepository(DataSource dataSource) { // <1> | ||
this.jdbcTemplate = new JdbcTemplate(DelegatingDataSource.unwrapDataSource(dataSource)); //<2> | ||
} | ||
|
||
@Transactional | ||
List<Book> findByTitle(@NonNull @NotNull String title) { | ||
return jdbcTemplate.queryForList('SELECT * FROM Book AS book WHERE book.title = ?', title) // <3> | ||
.collect(m -> new Book(m.id as Long, m.title as String, m.pages as Integer)) | ||
} | ||
} | ||
// end::clazz[] |
15 changes: 15 additions & 0 deletions
15
doc-examples/jdbc-spring-template-example-groovy/src/main/groovy/example/Book.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package example | ||
|
||
import groovy.transform.Canonical | ||
import io.micronaut.core.annotation.Nullable | ||
import io.micronaut.data.annotation.GeneratedValue | ||
import io.micronaut.data.annotation.Id | ||
import io.micronaut.data.annotation.MappedEntity | ||
|
||
@Canonical | ||
@MappedEntity | ||
class Book { | ||
@Id @GeneratedValue @Nullable Long id | ||
String title | ||
int pages | ||
} |
8 changes: 8 additions & 0 deletions
8
doc-examples/jdbc-spring-template-example-groovy/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
datasources: | ||
default: | ||
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=USER | ||
driverClassName: org.h2.Driver | ||
username: sa | ||
password: '' | ||
schema-generate: CREATE_DROP | ||
dialect: H2 |
12 changes: 12 additions & 0 deletions
12
doc-examples/jdbc-spring-template-example-groovy/src/main/resources/logback.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
44 changes: 44 additions & 0 deletions
44
...les/jdbc-spring-template-example-groovy/src/test/groovy/example/BookRepositorySpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package example | ||
|
||
import io.micronaut.context.annotation.Property | ||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
import jakarta.inject.Inject | ||
import spock.lang.Specification | ||
|
||
@MicronautTest(transactional = false) | ||
@Property(name = 'spec.name', value = 'BookRepositorySpec') | ||
@Property(name = 'datasources.default.name', value = 'mydb') | ||
@Property(name = 'datasources.default.transactionManager', value = 'springJdbc') | ||
@Property(name = 'jpa.default.properties.hibernate.hbm2ddl.auto', value = 'create-drop') | ||
class BookRepositorySpec extends Specification { | ||
|
||
@Inject | ||
AbstractBookRepository bookRepository | ||
|
||
void "test Books JdbcTemplate"() { | ||
given: | ||
bookRepository.saveAll([ | ||
new Book(null, 'The Stand', 1000), | ||
new Book(null, 'The Shining', 600), | ||
new Book(null, 'The Power of the Dog', 500), | ||
new Book(null, 'The Border', 700), | ||
new Book(null, 'Along Came a Spider', 300), | ||
new Book(null, 'Pet Cemetery', 400), | ||
new Book(null, 'A Game of Thrones', 900), | ||
new Book(null, 'A Clash of Kings', 1100) | ||
]) | ||
|
||
when: | ||
List<Book> result = bookRepository.findByTitle('The Shining') | ||
|
||
then: | ||
result.size() == 1 | ||
|
||
result[0].id != null | ||
result[0].title == 'The Shining' | ||
result[0].pages == 600 | ||
|
||
cleanup: | ||
bookRepository.deleteAll() | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
doc-examples/jdbc-spring-template-example-java/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
plugins { | ||
id "io.micronaut.build.internal.data-example" | ||
} | ||
|
||
micronaut { | ||
version libs.versions.micronaut.platform.get() | ||
runtime "netty" | ||
testRuntime "junit5" | ||
} | ||
|
||
dependencies { | ||
annotationProcessor projects.micronautDataProcessor | ||
annotationProcessor mnValidation.micronaut.validation.processor | ||
|
||
implementation projects.micronautDataJdbc | ||
implementation projects.micronautDataSpringJdbc | ||
implementation mnValidation.micronaut.validation | ||
|
||
runtimeOnly mnSql.micronaut.jdbc.tomcat | ||
runtimeOnly mnLogging.logback.classic | ||
runtimeOnly mnSql.h2 | ||
} |
1 change: 1 addition & 0 deletions
1
doc-examples/jdbc-spring-template-example-java/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
skipDocumentation=true |
36 changes: 36 additions & 0 deletions
36
...mples/jdbc-spring-template-example-java/src/main/java/example/AbstractBookRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package example; | ||
|
||
import io.micronaut.context.annotation.Requires; | ||
import io.micronaut.core.annotation.NonNull; | ||
import io.micronaut.data.connection.jdbc.advice.DelegatingDataSource; | ||
import io.micronaut.data.jdbc.annotation.JdbcRepository; | ||
import io.micronaut.data.model.query.builder.sql.Dialect; | ||
import io.micronaut.data.repository.CrudRepository; | ||
import jakarta.transaction.Transactional; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotNull; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
|
||
import javax.sql.DataSource; | ||
import java.util.List; | ||
|
||
@Requires(property = "spec.name", value = "BookRepositoryTest") | ||
// tag::clazz[] | ||
@JdbcRepository(dialect = Dialect.H2) | ||
public abstract class AbstractBookRepository implements CrudRepository<@Valid Book, @NotNull Long> { | ||
|
||
private final JdbcTemplate jdbcTemplate; //<2> | ||
|
||
public AbstractBookRepository(DataSource dataSource) { // <1> | ||
this.jdbcTemplate = new JdbcTemplate(DelegatingDataSource.unwrapDataSource(dataSource)); //<2> | ||
} | ||
|
||
@Transactional | ||
public List<Book> findByTitle(@NonNull @NotNull String title) { | ||
return jdbcTemplate.queryForList("SELECT * FROM Book AS book WHERE book.title = ?", title) // <3> | ||
.stream() | ||
.map(m -> new Book((Long) m.get("id"), (String) m.get("title"), (Integer) m.get("pages"))) | ||
.toList(); | ||
} | ||
} | ||
// end::clazz[] |
15 changes: 15 additions & 0 deletions
15
doc-examples/jdbc-spring-template-example-java/src/main/java/example/Book.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package example; | ||
|
||
import io.micronaut.core.annotation.Nullable; | ||
import io.micronaut.data.annotation.GeneratedValue; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
|
||
// tag::book[] | ||
@MappedEntity | ||
public record Book( | ||
@Id @GeneratedValue @Nullable Long id, | ||
String title, | ||
int pages | ||
) { } | ||
// end::book[] |
8 changes: 8 additions & 0 deletions
8
doc-examples/jdbc-spring-template-example-java/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
datasources: | ||
default: | ||
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=USER | ||
driverClassName: org.h2.Driver | ||
username: sa | ||
password: '' | ||
schema-generate: CREATE_DROP | ||
dialect: H2 |
12 changes: 12 additions & 0 deletions
12
doc-examples/jdbc-spring-template-example-java/src/main/resources/logback.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
50 changes: 50 additions & 0 deletions
50
doc-examples/jdbc-spring-template-example-java/src/test/java/example/BookRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package example; | ||
|
||
import io.micronaut.context.annotation.Property; | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
import jakarta.inject.Inject; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
@MicronautTest | ||
@Property(name = "spec.name", value = "BookRepositoryTest") | ||
@Property(name = "datasources.default.name", value = "mydb") | ||
@Property(name = "datasources.default.transactionManager", value = "springJdbc") | ||
@Property(name = "jpa.default.properties.hibernate.hbm2ddl.auto", value = "create-drop") | ||
class BookRepositoryTest { | ||
|
||
@Inject | ||
AbstractBookRepository bookRepository; | ||
|
||
@AfterEach | ||
void cleanup() { | ||
bookRepository.deleteAll(); | ||
} | ||
|
||
@Test | ||
void testBooksJdbcTemplate() { | ||
bookRepository.saveAll(Arrays.asList( | ||
new Book(null,"The Stand", 1000), | ||
new Book(null,"The Shining", 600), | ||
new Book(null,"The Power of the Dog", 500), | ||
new Book(null,"The Border", 700), | ||
new Book(null,"Along Came a Spider", 300), | ||
new Book(null,"Pet Cemetery", 400), | ||
new Book(null,"A Game of Thrones", 900), | ||
new Book(null,"A Clash of Kings", 1100) | ||
)); | ||
|
||
List<Book> result = bookRepository.findByTitle("The Shining"); | ||
assertEquals(1, result.size()); | ||
|
||
assertNotNull(result.get(0).id()); | ||
assertEquals("The Shining", result.get(0).title()); | ||
assertEquals(600, result.get(0).pages()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
doc-examples/jdbc-spring-template-example-kotlin/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
plugins { | ||
id "org.jetbrains.kotlin.jvm" | ||
id "org.jetbrains.kotlin.kapt" | ||
id "org.jetbrains.kotlin.plugin.allopen" | ||
id "io.micronaut.build.internal.data-kotlin-example" | ||
} | ||
|
||
micronaut { | ||
version libs.versions.micronaut.platform.get() | ||
runtime "netty" | ||
testRuntime "junit5" | ||
} | ||
|
||
dependencies { | ||
kapt projects.micronautDataProcessor | ||
kapt mnValidation.micronaut.validation.processor | ||
|
||
implementation projects.micronautDataJdbc | ||
implementation projects.micronautDataSpringJdbc | ||
implementation mnValidation.micronaut.validation | ||
|
||
runtimeOnly mnSql.micronaut.jdbc.tomcat | ||
runtimeOnly mnLogging.logback.classic | ||
runtimeOnly mnSql.h2 | ||
} |
1 change: 1 addition & 0 deletions
1
doc-examples/jdbc-spring-template-example-kotlin/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
skipDocumentation=true |
25 changes: 25 additions & 0 deletions
25
...les/jdbc-spring-template-example-kotlin/src/main/kotlin/example/AbstractBookRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package example | ||
|
||
import io.micronaut.context.annotation.Requires | ||
import io.micronaut.data.connection.jdbc.advice.DelegatingDataSource | ||
import io.micronaut.data.jdbc.annotation.JdbcRepository | ||
import io.micronaut.data.model.query.builder.sql.Dialect | ||
import io.micronaut.data.repository.CrudRepository | ||
import jakarta.transaction.Transactional | ||
import jakarta.validation.Valid | ||
import javax.sql.DataSource | ||
import org.springframework.jdbc.core.JdbcTemplate | ||
|
||
@Requires(property = "spec.name", value = "BookRepositoryTest") // tag::clazz[] | ||
// tag::clazz[] | ||
@JdbcRepository(dialect = Dialect.H2) | ||
abstract class AbstractBookRepository(dataSource: DataSource) : CrudRepository<@Valid Book, Long> { // <1> | ||
|
||
private val jdbcTemplate: JdbcTemplate = JdbcTemplate(DelegatingDataSource.unwrapDataSource(dataSource)) //<2> | ||
|
||
@Transactional | ||
open fun findByTitle(title: String) = jdbcTemplate | ||
.queryForList("SELECT * FROM Book AS book WHERE book.title = ?", title) // <3> | ||
.map { m -> Book(m["id"] as Long, m["title"] as String, m["pages"] as Int) } | ||
} | ||
// end::clazz[] |
14 changes: 14 additions & 0 deletions
14
doc-examples/jdbc-spring-template-example-kotlin/src/main/kotlin/example/Book.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package example | ||
|
||
import io.micronaut.data.annotation.GeneratedValue | ||
import io.micronaut.data.annotation.Id | ||
import io.micronaut.data.annotation.MappedEntity | ||
|
||
// tag::book[] | ||
@MappedEntity | ||
data class Book( | ||
@field:Id @field:GeneratedValue val id: Long?, | ||
val title: String, | ||
val pages: Int | ||
) | ||
// end::book[] |
8 changes: 8 additions & 0 deletions
8
doc-examples/jdbc-spring-template-example-kotlin/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
datasources: | ||
default: | ||
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=USER | ||
driverClassName: org.h2.Driver | ||
username: sa | ||
password: '' | ||
schema-generate: CREATE_DROP | ||
dialect: H2 |
12 changes: 12 additions & 0 deletions
12
doc-examples/jdbc-spring-template-example-kotlin/src/main/resources/logback.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the JdbcTemplate be injected directly without the need of instantiating it manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that didn't work for me, and even in that case it did, it still needs a DataSource set before you can use it. I patterned this after what is done in: https://github.com/micronaut-projects/micronaut-data/blob/master/data-spring-jdbc/src/main/java/io/micronaut/data/spring/jdbc/SpringJdbcConnectionOperations.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we could create a factory that does the same thing, and then it could be injected.