Skip to content
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 9 commits into from
Sep 18, 2023

Conversation

wetted
Copy link
Contributor

@wetted wetted commented Sep 6, 2023

close #2423

@wetted wetted requested a review from timyates September 6, 2023 21:39
@wetted wetted self-assigned this Sep 6, 2023
src/main/docs/guide/dbc/dbcRepositories.adoc Outdated Show resolved Hide resolved
src/main/docs/guide/dbc/dbcRepositories.adoc Outdated Show resolved Hide resolved
@wetted wetted marked this pull request as ready for review September 7, 2023 14:17
@JdbcRepository(dialect = Dialect.H2)
abstract class AbstractBookRepository implements CrudRepository<@Valid Book, @NotNull Long> {

private final JdbcTemplate jdbcTemplate; //<2>
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

src/main/docs/guide/dbc/dbcRepositories.adoc Outdated Show resolved Hide resolved
@wetted wetted requested a review from sdelamo September 13, 2023 15:30
@sdelamo
Copy link
Contributor

sdelamo commented Sep 15, 2023

ping @dstepanov

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sdelamo sdelamo merged commit b008284 into master Sep 18, 2023
@sdelamo sdelamo deleted the spring-jdbctemplate-docs branch September 18, 2023 10:08
@radovanradic
Copy link
Contributor

@sdelamo Looks like these doc-examples/jdbc-spring-template-xxx are failing
https://ge.micronaut.io/s/sznpcbjjr6po2

Failed to inject value for parameter [transactionManager] of class: io.micronaut.transaction.test.DefaultTestTransactionExecutionListener
Message: Multiple possible bean candidates found: [SpringJdbcTransactionOperations, DataSourceTransactionManager]

@wetted
Copy link
Contributor Author

wetted commented Sep 19, 2023

@sdelamo Looks like these doc-examples/jdbc-spring-template-xxx are failing https://ge.micronaut.io/s/sznpcbjjr6po2

Failed to inject value for parameter [transactionManager] of class: io.micronaut.transaction.test.DefaultTestTransactionExecutionListener
Message: Multiple possible bean candidates found: [SpringJdbcTransactionOperations, DataSourceTransactionManager]

@radovanradic Is this repeatable for you? I just ran the check task locally on master and the tests pass for me.

@radovanradic
Copy link
Contributor

@wetted Not anymore it seems. Was getting it today on 4.1.x consistently. Maybe didn't pick up Sergio's merge. Seems to be working fine now. Sorry for false alarm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Explain users how to use Spring JDBC Template
5 participants