Skip to content

Conversation

@zhfeng
Copy link
Contributor

@zhfeng zhfeng commented Apr 28, 2021

@zhfeng zhfeng marked this pull request as draft April 28, 2021 06:19
@zhfeng
Copy link
Contributor Author

zhfeng commented Apr 28, 2021

This needs a new release of quarkus-mybatis

@zhfeng zhfeng marked this pull request as ready for review April 28, 2021 12:57
Copy link
Contributor

@ppalaga ppalaga left a 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>
Copy link
Contributor

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>
Copy link
Contributor

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.

Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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()));
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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 ?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Comment on lines 86 to 89
RestAssured.delete("/mybatis/deleteOne?id=456")
.then()
.statusCode(200)
.body(equalTo("1"));
Copy link
Contributor

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().

Copy link
Contributor Author

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.

Copy link
Contributor

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.

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 just move all of the tests in one @test method so them can run orderly

Copy link
Contributor

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.

@zhfeng
Copy link
Contributor Author

zhfeng commented Apr 28, 2021

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.

@zhfeng zhfeng marked this pull request as draft April 28, 2021 14:04
@zhfeng
Copy link
Contributor Author

zhfeng commented Jul 9, 2021

@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.

@zhfeng zhfeng force-pushed the issue_1384_mybatis_native_support branch from 4316402 to 3cd88ed Compare January 4, 2022 16:00
@zhfeng
Copy link
Contributor Author

zhfeng commented Jan 4, 2022

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

@zhfeng zhfeng force-pushed the issue_1384_mybatis_native_support branch from 3cd88ed to 5c9c973 Compare February 8, 2022 13:04
@zhfeng zhfeng changed the title [WIP] Fix #1384 camel-mybatis native support Fix #1384 camel-mybatis native support Feb 8, 2022
@zhfeng zhfeng marked this pull request as ready for review February 8, 2022 15:25
@zhfeng
Copy link
Contributor Author

zhfeng commented Feb 8, 2022

@ppalaga I upgrade the GA release of quarkus-mybatis and it should fix to remove the --report-unsupported-elements-at-runtime option in native building. I think it is a good shape now.

@ppalaga
Copy link
Contributor

ppalaga commented Feb 8, 2022

@zhfeng could you please rebase on top recent main to get rid of the ipfs failures?

@zhfeng zhfeng force-pushed the issue_1384_mybatis_native_support branch from 5c9c973 to 3b79122 Compare February 9, 2022 02:43
@zhfeng
Copy link
Contributor Author

zhfeng commented Feb 9, 2022

@ppalaga can we go for merging it since CI looks good ?

@ppalaga
Copy link
Contributor

ppalaga commented Feb 9, 2022

@ppalaga can we go for merging it since CI looks good ?

Yes, thank you very much for the contribution!

@ppalaga ppalaga merged commit 143ee21 into apache:main Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants