-
Notifications
You must be signed in to change notification settings - Fork 210
Fix #1384 camel-mybatis native support #2525
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
Conversation
|
This needs a new release of quarkus-mybatis |
ppalaga
left a comment
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 vote for merging this only if --report-unsupported-elements-at-runtime is not required.
| [source, xml] | ||
| ---- | ||
| <properties> | ||
| <quarkus.package.type>native</quarkus.package.type> |
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.
<quarkus.package.type>native</quarkus.package.type> is not MyBatis specific and it does not need to be documented here.
| ---- | ||
| <properties> | ||
| <quarkus.package.type>native</quarkus.package.type> | ||
| <quarkus.native.additional-build-args>--report-unsupported-elements-at-runtime</quarkus.native.additional-build-args> |
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.
Could you please explain why is this required? We generally do not want any additional-build-args.
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.
OK, now I see there is quarkiverse/quarkus-mybatis#10 . I'd prefer not merging this unless quarkiverse/quarkus-mybatis#10 is fixed, or unless there is a clear idea how it can be fixed.
| @Record(ExecutionTime.STATIC_INIT) | ||
| @BuildStep | ||
| CamelBeanBuildItem mybatisComponent( | ||
| List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) { |
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.
Why List<SqlSessionFactoryBuildItem>? Can there be more than one SqlSessionFactoryBuildItem?
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.
yeah, this was introduced to support multi datasource support see quarkiverse/quarkus-mybatis#68
| CamelBeanBuildItem mybatisBeanComponent( | ||
| List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) { | ||
| return new CamelBeanBuildItem("mybatis-bean", MyBatisBeanComponent.class.getName(), | ||
| recorder.createMyBatisBeanComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory())); |
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 we be sure that sqlSessionFactoryBuildItem is not empty?
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.
sure, I create quarkiverse/quarkus-mybatis#74 for improving it when using mybatis xml configuration.
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 did not ask for not creating sqlSessionFactory for each data source. (I have no idea whether that makes sense for Quarkivese MyBatis at all). I asked about the case when the list of sqlSessionFactoryBuildItems is empty. Is it made impossible somewhere in Quarkivese MyBatis or here? Because otherwise sqlSessionFactoryBuildItem.get(0) may throw an ArrayIndexOutOfBoundsException or similar and it would not inform the end user that (and where) he needs to define a datasource.
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.
OK, I get it and I think it should be in Quarkivese MyBatis to make sure to create at least one sqlSessionFactory. Also do you know if it is possible to set quarkus.mybatis.xmlconfig.enable=true automatically when the camel-quarkus-mybatis extension is activated ?
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 think the cleanest way would be to have a dedicated XmlConfigEnabledBuildItem for that in Quarkivese MyBatis. Other options I can think of are hacks.
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.
Thanks @ppalaga and I will try this idea in quarkiverse/quarkus-mybatis#84
...sts/mybatis/src/main/java/org/apache/camel/quarkus/component/mybatis/it/MybatisResource.java
Outdated
Show resolved
Hide resolved
...n-tests/mybatis/src/test/java/org/apache/camel/quarkus/component/mybatis/it/MyBatisTest.java
Outdated
Show resolved
Hide resolved
| RestAssured.delete("/mybatis/deleteOne?id=456") | ||
| .then() | ||
| .statusCode(200) | ||
| .body(equalTo("1")); |
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.
Running testDelete() before testSelectOne() would make testSelectOne() fail. You should not assume any particular test method execution order. You may want to move this code to testSelectOne().
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.
The MyBatisResource uses @transactional and marks the transaction with rollback only. So all of the changes will not persist in the database.
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 have not noticed that, thanks for the explanation. However, to ensure that the persistence layer really works, I think it would be better to test with a non-rollback transaction manager and always do a followup read call to ensure that the insert/update/delete was successful.
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 just move all of the tests in one @test method so them can run orderly
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 just move all of the tests in one @test method so them can run orderly
Yeah, thanks, that's what we mostly do in case like this one.
|
Thanks @ppalaga for reviewing and I agree to not merge this PR until quarkiverse/quarkus-mybatis#10 get resolved. I just raise it for getting some feedback and make sure the mybatis xml configuration works with camel-mybatis. |
|
@ppalaga I got some progress on quarkiverse/quarkus-mybatis#10 and I think it could be fixed with mybatis/mybatis-3#2284. So I'm waiting for the new mybatis release of 3.5.8 and come back to work with this PR. |
4316402 to
3cd88ed
Compare
|
quarkus-mybatis 0.0.11 bump mybatis to 3.5.8 and it still needs to bump mybatis version in camel-3.14.x refer to apache/camel#6632 |
3cd88ed to
5c9c973
Compare
|
@ppalaga I upgrade the GA release of |
|
@zhfeng could you please rebase on top recent main to get rid of the ipfs failures? |
5c9c973 to
3b79122
Compare
|
@ppalaga can we go for merging it since CI looks good ? |
Yes, thank you very much for the contribution! |
quarkus.mybatis.xmlconfig.enable=truein application.properties<dataSource type="QUARKUS">in mybatis xml configuration file--report-unsupported-elements-at-runtimein the native mode currently and should be removed when Investigate to remove the --report-unsupported-elements-at-runtime in native mode quarkiverse/quarkus-mybatis#10 get resolved