You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/04/28 06:19:17 UTC

[GitHub] [camel-quarkus] zhfeng opened a new pull request #2525: [WIP] Fix #1384 camel-mybatis native support

zhfeng opened a new pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525


   [x] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
   [ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
   [ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
   [ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
   [ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
   [ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r623127836



##########
File path: integration-tests/mybatis/src/test/java/org/apache/camel/quarkus/component/mybatis/it/MyBatisTest.java
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.mybatis.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.h2.H2DatabaseTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.mybatis.it.entity.Account;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+@QuarkusTestResource(H2DatabaseTestResource.class)
+public class MyBatisTest {
+
+    @Test
+    public void loadComponentMybatis() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void loadComponentMybatisBean() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis-bean")
+                .then()
+                .statusCode(200);
+    }

Review comment:
       Done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r623764695



##########
File path: integration-tests/mybatis/src/test/java/org/apache/camel/quarkus/component/mybatis/it/MyBatisTest.java
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.mybatis.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.h2.H2DatabaseTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.mybatis.it.entity.Account;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+@QuarkusTestResource(H2DatabaseTestResource.class)
+public class MyBatisTest {
+
+    @Test
+    public void loadComponentMybatis() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void loadComponentMybatisBean() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis-bean")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void testSelectOne() {
+        RestAssured.get("/mybatis/selectOne?id=456")
+                .then()
+                .statusCode(200)
+                .body("id", equalTo(456))
+                .body("firstName", equalTo("Claus"))
+                .body("lastName", equalTo("Ibsen"))
+                .body("emailAddress", equalTo("Noname@gmail.com"));
+    }
+
+    @Test
+    public void testSelectOneNotFound() {
+        RestAssured.get("/mybatis/selectOne?id=999")
+                .then()
+                .statusCode(404);
+    }
+
+    @Test
+    public void testInsert() {
+        Account account = new Account();
+        account.setId(444);
+        account.setFirstName("Willem");
+        account.setLastName("Jiang");
+        account.setEmailAddress("Faraway@gmail.com");
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(account)
+                .post("/mybatis/insertOne")
+                .then()
+                .statusCode(200)
+                .body(equalTo("3"));
+    }
+
+    @Test
+    public void testDelete() {
+        RestAssured.delete("/mybatis/deleteOne?id=456")
+                .then()
+                .statusCode(200)
+                .body(equalTo("1"));

Review comment:
       > 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.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r623127504



##########
File path: extensions/mybatis/deployment/src/main/java/org/apache/camel/quarkus/component/mybatis/deployment/MybatisProcessor.java
##########
@@ -34,13 +39,19 @@ FeatureBuildItem feature() {
         return new FeatureBuildItem(FEATURE);
     }
 
-    /**
-     * Remove this once this extension starts supporting the native mode.
-     */
-    @BuildStep(onlyIf = NativeBuild.class)
-    @Record(value = ExecutionTime.RUNTIME_INIT)
-    void warnJvmInNative(JvmOnlyRecorder recorder) {
-        JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
-        recorder.warnJvmInNative(FEATURE); // warn at runtime
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis", MyBatisComponent.class.getName(),
+                recorder.createMyBatisComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));
+    }
+
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisBeanComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis-bean", MyBatisBeanComponent.class.getName(),
+                recorder.createMyBatisBeanComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));

Review comment:
       Thanks @ppalaga and I will try this idea in https://github.com/quarkiverse/quarkus-mybatis/issues/84

##########
File path: integration-tests/mybatis/src/main/java/org/apache/camel/quarkus/component/mybatis/it/MybatisResource.java
##########
@@ -61,4 +77,44 @@ public Response loadComponentMybatisBean() throws Exception {
         LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_MYBATIS_BEAN);
         return Response.status(500, COMPONENT_MYBATIS_BEAN + " could not be loaded from the Camel context").build();
     }
+

Review comment:
       Done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#issuecomment-828482969


   Thanks @ppalaga for reviewing and I agree to not merge this PR until https://github.com/quarkiverse/quarkus-mybatis/issues/10 get resolved. I just raise it for getting some feedback and make sure the mybatis xml configuration works with camel-mybatis.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r622272257



##########
File path: extensions/mybatis/deployment/src/main/java/org/apache/camel/quarkus/component/mybatis/deployment/MybatisProcessor.java
##########
@@ -34,13 +39,19 @@ FeatureBuildItem feature() {
         return new FeatureBuildItem(FEATURE);
     }
 
-    /**
-     * Remove this once this extension starts supporting the native mode.
-     */
-    @BuildStep(onlyIf = NativeBuild.class)
-    @Record(value = ExecutionTime.RUNTIME_INIT)
-    void warnJvmInNative(JvmOnlyRecorder recorder) {
-        JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
-        recorder.warnJvmInNative(FEATURE); // warn at runtime
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis", MyBatisComponent.class.getName(),
+                recorder.createMyBatisComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));
+    }
+
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisBeanComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis-bean", MyBatisBeanComponent.class.getName(),
+                recorder.createMyBatisBeanComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));

Review comment:
       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.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r622311445



##########
File path: extensions/mybatis/deployment/src/main/java/org/apache/camel/quarkus/component/mybatis/deployment/MybatisProcessor.java
##########
@@ -34,13 +39,19 @@ FeatureBuildItem feature() {
         return new FeatureBuildItem(FEATURE);
     }
 
-    /**
-     * Remove this once this extension starts supporting the native mode.
-     */
-    @BuildStep(onlyIf = NativeBuild.class)
-    @Record(value = ExecutionTime.RUNTIME_INIT)
-    void warnJvmInNative(JvmOnlyRecorder recorder) {
-        JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
-        recorder.warnJvmInNative(FEATURE); // warn at runtime
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis", MyBatisComponent.class.getName(),
+                recorder.createMyBatisComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));
+    }
+
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisBeanComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis-bean", MyBatisBeanComponent.class.getName(),
+                recorder.createMyBatisBeanComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));

Review comment:
       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 ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on pull request #2525: Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#issuecomment-1033951521


   > @ppalaga can we go for merging it since CI looks good ?
   
   Yes, thank you very much for the contribution!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#issuecomment-828178408


   This needs a new release of [quarkus-mybatis](https://github.com/quarkiverse/quarkus-mybatis)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r622174997



##########
File path: docs/modules/ROOT/pages/reference/extensions/mybatis.adoc
##########
@@ -34,3 +38,25 @@ Please refer to the above links for usage and configuration details.
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Additional Camel Quarkus configuration
+
+Please refer to https://quarkiverse.github.io/quarkiverse-docs/quarkus-mybatis/dev/index.html[Quarkus MyBatis] for configuration. It must enable the following options
+
+[source, properties]
+----
+quarkus.mybatis.xmlconfig.enable=true
+quarkus.mybatis.xmlconfig.path=SqlMapConfig.xml
+----
+TIP: `quarkus.mybatis.xmlconfig.path` must be the same with `configurationUri` param in the mybatis endpoint.
+
+If you want to run in the native mode, you have to set these properties in pom.xml currently.
+
+[source, xml]
+----
+<properties>
+    <quarkus.package.type>native</quarkus.package.type>

Review comment:
       `<quarkus.package.type>native</quarkus.package.type>` is not MyBatis specific and it does not need to be documented here. 

##########
File path: integration-tests/mybatis/src/test/java/org/apache/camel/quarkus/component/mybatis/it/MyBatisTest.java
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.mybatis.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.h2.H2DatabaseTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.mybatis.it.entity.Account;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+@QuarkusTestResource(H2DatabaseTestResource.class)
+public class MyBatisTest {
+
+    @Test
+    public void loadComponentMybatis() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void loadComponentMybatisBean() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis-bean")
+                .then()
+                .statusCode(200);
+    }

Review comment:
       ```suggestion
   ```
   
   Please remove the auto-generated tests

##########
File path: extensions/mybatis/deployment/src/main/java/org/apache/camel/quarkus/component/mybatis/deployment/MybatisProcessor.java
##########
@@ -34,13 +39,19 @@ FeatureBuildItem feature() {
         return new FeatureBuildItem(FEATURE);
     }
 
-    /**
-     * Remove this once this extension starts supporting the native mode.
-     */
-    @BuildStep(onlyIf = NativeBuild.class)
-    @Record(value = ExecutionTime.RUNTIME_INIT)
-    void warnJvmInNative(JvmOnlyRecorder recorder) {
-        JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
-        recorder.warnJvmInNative(FEATURE); // warn at runtime
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis", MyBatisComponent.class.getName(),
+                recorder.createMyBatisComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));
+    }
+
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisBeanComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis-bean", MyBatisBeanComponent.class.getName(),
+                recorder.createMyBatisBeanComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));

Review comment:
       Can we be sure that sqlSessionFactoryBuildItem is not empty?

##########
File path: integration-tests/mybatis/src/test/java/org/apache/camel/quarkus/component/mybatis/it/MyBatisTest.java
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.mybatis.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.h2.H2DatabaseTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.mybatis.it.entity.Account;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+@QuarkusTestResource(H2DatabaseTestResource.class)
+public class MyBatisTest {
+
+    @Test
+    public void loadComponentMybatis() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void loadComponentMybatisBean() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis-bean")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void testSelectOne() {
+        RestAssured.get("/mybatis/selectOne?id=456")
+                .then()
+                .statusCode(200)
+                .body("id", equalTo(456))
+                .body("firstName", equalTo("Claus"))
+                .body("lastName", equalTo("Ibsen"))
+                .body("emailAddress", equalTo("Noname@gmail.com"));
+    }
+
+    @Test
+    public void testSelectOneNotFound() {
+        RestAssured.get("/mybatis/selectOne?id=999")
+                .then()
+                .statusCode(404);
+    }
+
+    @Test
+    public void testInsert() {
+        Account account = new Account();
+        account.setId(444);
+        account.setFirstName("Willem");
+        account.setLastName("Jiang");
+        account.setEmailAddress("Faraway@gmail.com");
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(account)
+                .post("/mybatis/insertOne")
+                .then()
+                .statusCode(200)
+                .body(equalTo("3"));
+    }
+
+    @Test
+    public void testDelete() {
+        RestAssured.delete("/mybatis/deleteOne?id=456")
+                .then()
+                .statusCode(200)
+                .body(equalTo("1"));

Review comment:
       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()`.

##########
File path: extensions/mybatis/deployment/src/main/java/org/apache/camel/quarkus/component/mybatis/deployment/MybatisProcessor.java
##########
@@ -34,13 +39,19 @@ FeatureBuildItem feature() {
         return new FeatureBuildItem(FEATURE);
     }
 
-    /**
-     * Remove this once this extension starts supporting the native mode.
-     */
-    @BuildStep(onlyIf = NativeBuild.class)
-    @Record(value = ExecutionTime.RUNTIME_INIT)
-    void warnJvmInNative(JvmOnlyRecorder recorder) {
-        JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
-        recorder.warnJvmInNative(FEATURE); // warn at runtime
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {

Review comment:
       Why `List<SqlSessionFactoryBuildItem>`? Can there be more than one `SqlSessionFactoryBuildItem`? 

##########
File path: docs/modules/ROOT/pages/reference/extensions/mybatis.adoc
##########
@@ -34,3 +38,25 @@ Please refer to the above links for usage and configuration details.
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Additional Camel Quarkus configuration
+
+Please refer to https://quarkiverse.github.io/quarkiverse-docs/quarkus-mybatis/dev/index.html[Quarkus MyBatis] for configuration. It must enable the following options
+
+[source, properties]
+----
+quarkus.mybatis.xmlconfig.enable=true
+quarkus.mybatis.xmlconfig.path=SqlMapConfig.xml
+----
+TIP: `quarkus.mybatis.xmlconfig.path` must be the same with `configurationUri` param in the mybatis endpoint.
+
+If you want to run in the native mode, you have to set these properties in pom.xml currently.
+
+[source, xml]
+----
+<properties>
+    <quarkus.package.type>native</quarkus.package.type>
+    <quarkus.native.additional-build-args>--report-unsupported-elements-at-runtime</quarkus.native.additional-build-args>

Review comment:
       OK, now I see there is https://github.com/quarkiverse/quarkus-mybatis/issues/10 . I'd prefer not merging this unless https://github.com/quarkiverse/quarkus-mybatis/issues/10 is fixed, or unless there is a clear idea how it can be fixed. 

##########
File path: docs/modules/ROOT/pages/reference/extensions/mybatis.adoc
##########
@@ -34,3 +38,25 @@ Please refer to the above links for usage and configuration details.
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Additional Camel Quarkus configuration
+
+Please refer to https://quarkiverse.github.io/quarkiverse-docs/quarkus-mybatis/dev/index.html[Quarkus MyBatis] for configuration. It must enable the following options
+
+[source, properties]
+----
+quarkus.mybatis.xmlconfig.enable=true
+quarkus.mybatis.xmlconfig.path=SqlMapConfig.xml
+----
+TIP: `quarkus.mybatis.xmlconfig.path` must be the same with `configurationUri` param in the mybatis endpoint.
+
+If you want to run in the native mode, you have to set these properties in pom.xml currently.
+
+[source, xml]
+----
+<properties>
+    <quarkus.package.type>native</quarkus.package.type>
+    <quarkus.native.additional-build-args>--report-unsupported-elements-at-runtime</quarkus.native.additional-build-args>

Review comment:
       Could you please explain why is this required? We generally do not want any `additional-build-args`. 

##########
File path: integration-tests/mybatis/src/main/java/org/apache/camel/quarkus/component/mybatis/it/MybatisResource.java
##########
@@ -61,4 +77,44 @@ public Response loadComponentMybatisBean() throws Exception {
         LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_MYBATIS_BEAN);
         return Response.status(500, COMPONENT_MYBATIS_BEAN + " could not be loaded from the Camel context").build();
     }
+

Review comment:
       Could you please remove the original auto-generated test ensdpoints `loadComponentMybatis()` and `loadComponentMybatisBean()`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#issuecomment-1004935124


   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 https://github.com/apache/camel/pull/6632


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on pull request #2525: Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#issuecomment-1032804764


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r623128580



##########
File path: integration-tests/mybatis/src/test/java/org/apache/camel/quarkus/component/mybatis/it/MyBatisTest.java
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.mybatis.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.h2.H2DatabaseTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.mybatis.it.entity.Account;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+@QuarkusTestResource(H2DatabaseTestResource.class)
+public class MyBatisTest {
+
+    @Test
+    public void loadComponentMybatis() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void loadComponentMybatisBean() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis-bean")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void testSelectOne() {
+        RestAssured.get("/mybatis/selectOne?id=456")
+                .then()
+                .statusCode(200)
+                .body("id", equalTo(456))
+                .body("firstName", equalTo("Claus"))
+                .body("lastName", equalTo("Ibsen"))
+                .body("emailAddress", equalTo("Noname@gmail.com"));
+    }
+
+    @Test
+    public void testSelectOneNotFound() {
+        RestAssured.get("/mybatis/selectOne?id=999")
+                .then()
+                .statusCode(404);
+    }
+
+    @Test
+    public void testInsert() {
+        Account account = new Account();
+        account.setId(444);
+        account.setFirstName("Willem");
+        account.setLastName("Jiang");
+        account.setEmailAddress("Faraway@gmail.com");
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(account)
+                .post("/mybatis/insertOne")
+                .then()
+                .statusCode(200)
+                .body(equalTo("3"));
+    }
+
+    @Test
+    public void testDelete() {
+        RestAssured.delete("/mybatis/deleteOne?id=456")
+                .then()
+                .statusCode(200)
+                .body(equalTo("1"));

Review comment:
       I just move all of the tests in one @Test method so them can run orderly




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r622206637



##########
File path: integration-tests/mybatis/src/main/java/org/apache/camel/quarkus/component/mybatis/it/MybatisResource.java
##########
@@ -61,4 +77,44 @@ public Response loadComponentMybatisBean() throws Exception {
         LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_MYBATIS_BEAN);
         return Response.status(500, COMPONENT_MYBATIS_BEAN + " could not be loaded from the Camel context").build();
     }
+

Review comment:
       yeah, I will do.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on pull request #2525: Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#issuecomment-1033616188


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r622208629



##########
File path: integration-tests/mybatis/src/test/java/org/apache/camel/quarkus/component/mybatis/it/MyBatisTest.java
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.mybatis.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.h2.H2DatabaseTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.mybatis.it.entity.Account;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+@QuarkusTestResource(H2DatabaseTestResource.class)
+public class MyBatisTest {
+
+    @Test
+    public void loadComponentMybatis() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void loadComponentMybatisBean() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis-bean")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void testSelectOne() {
+        RestAssured.get("/mybatis/selectOne?id=456")
+                .then()
+                .statusCode(200)
+                .body("id", equalTo(456))
+                .body("firstName", equalTo("Claus"))
+                .body("lastName", equalTo("Ibsen"))
+                .body("emailAddress", equalTo("Noname@gmail.com"));
+    }
+
+    @Test
+    public void testSelectOneNotFound() {
+        RestAssured.get("/mybatis/selectOne?id=999")
+                .then()
+                .statusCode(404);
+    }
+
+    @Test
+    public void testInsert() {
+        Account account = new Account();
+        account.setId(444);
+        account.setFirstName("Willem");
+        account.setLastName("Jiang");
+        account.setEmailAddress("Faraway@gmail.com");
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(account)
+                .post("/mybatis/insertOne")
+                .then()
+                .statusCode(200)
+                .body(equalTo("3"));
+    }
+
+    @Test
+    public void testDelete() {
+        RestAssured.delete("/mybatis/deleteOne?id=456")
+                .then()
+                .statusCode(200)
+                .body(equalTo("1"));

Review comment:
       The MyBatisResource uses @Transactional and marks the transaction with rollback only. So all of the changes will not persist in the database.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r622204590



##########
File path: extensions/mybatis/deployment/src/main/java/org/apache/camel/quarkus/component/mybatis/deployment/MybatisProcessor.java
##########
@@ -34,13 +39,19 @@ FeatureBuildItem feature() {
         return new FeatureBuildItem(FEATURE);
     }
 
-    /**
-     * Remove this once this extension starts supporting the native mode.
-     */
-    @BuildStep(onlyIf = NativeBuild.class)
-    @Record(value = ExecutionTime.RUNTIME_INIT)
-    void warnJvmInNative(JvmOnlyRecorder recorder) {
-        JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
-        recorder.warnJvmInNative(FEATURE); // warn at runtime
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {

Review comment:
       yeah, this was introduced to support multi datasource support see https://github.com/quarkiverse/quarkus-mybatis/pull/68




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on pull request #2525: Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#issuecomment-1032739309


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r622337826



##########
File path: integration-tests/mybatis/src/test/java/org/apache/camel/quarkus/component/mybatis/it/MyBatisTest.java
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.mybatis.it;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.h2.H2DatabaseTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.mybatis.it.entity.Account;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+@QuarkusTestResource(H2DatabaseTestResource.class)
+public class MyBatisTest {
+
+    @Test
+    public void loadComponentMybatis() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void loadComponentMybatisBean() {
+        /* A simple autogenerated test */
+        RestAssured.get("/mybatis/load/component/mybatis-bean")
+                .then()
+                .statusCode(200);
+    }
+
+    @Test
+    public void testSelectOne() {
+        RestAssured.get("/mybatis/selectOne?id=456")
+                .then()
+                .statusCode(200)
+                .body("id", equalTo(456))
+                .body("firstName", equalTo("Claus"))
+                .body("lastName", equalTo("Ibsen"))
+                .body("emailAddress", equalTo("Noname@gmail.com"));
+    }
+
+    @Test
+    public void testSelectOneNotFound() {
+        RestAssured.get("/mybatis/selectOne?id=999")
+                .then()
+                .statusCode(404);
+    }
+
+    @Test
+    public void testInsert() {
+        Account account = new Account();
+        account.setId(444);
+        account.setFirstName("Willem");
+        account.setLastName("Jiang");
+        account.setEmailAddress("Faraway@gmail.com");
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(account)
+                .post("/mybatis/insertOne")
+                .then()
+                .statusCode(200)
+                .body(equalTo("3"));
+    }
+
+    @Test
+    public void testDelete() {
+        RestAssured.delete("/mybatis/deleteOne?id=456")
+                .then()
+                .statusCode(200)
+                .body(equalTo("1"));

Review comment:
       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. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#issuecomment-877033187


   @ppalaga I got some progress on https://github.com/quarkiverse/quarkus-mybatis/issues/10 and I think it could be fixed with https://github.com/mybatis/mybatis-3/pull/2284. So I'm waiting for the new mybatis release of 3.5.8 and come back to work with this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] zhfeng commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
zhfeng commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r622206349



##########
File path: extensions/mybatis/deployment/src/main/java/org/apache/camel/quarkus/component/mybatis/deployment/MybatisProcessor.java
##########
@@ -34,13 +39,19 @@ FeatureBuildItem feature() {
         return new FeatureBuildItem(FEATURE);
     }
 
-    /**
-     * Remove this once this extension starts supporting the native mode.
-     */
-    @BuildStep(onlyIf = NativeBuild.class)
-    @Record(value = ExecutionTime.RUNTIME_INIT)
-    void warnJvmInNative(JvmOnlyRecorder recorder) {
-        JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
-        recorder.warnJvmInNative(FEATURE); // warn at runtime
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis", MyBatisComponent.class.getName(),
+                recorder.createMyBatisComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));
+    }
+
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisBeanComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis-bean", MyBatisBeanComponent.class.getName(),
+                recorder.createMyBatisBeanComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));

Review comment:
       sure, I create https://github.com/quarkiverse/quarkus-mybatis/issues/74 for improving it when using mybatis xml configuration.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #2525: [WIP] Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r622340239



##########
File path: extensions/mybatis/deployment/src/main/java/org/apache/camel/quarkus/component/mybatis/deployment/MybatisProcessor.java
##########
@@ -34,13 +39,19 @@ FeatureBuildItem feature() {
         return new FeatureBuildItem(FEATURE);
     }
 
-    /**
-     * Remove this once this extension starts supporting the native mode.
-     */
-    @BuildStep(onlyIf = NativeBuild.class)
-    @Record(value = ExecutionTime.RUNTIME_INIT)
-    void warnJvmInNative(JvmOnlyRecorder recorder) {
-        JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
-        recorder.warnJvmInNative(FEATURE); // warn at runtime
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis", MyBatisComponent.class.getName(),
+                recorder.createMyBatisComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));
+    }
+
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    CamelBeanBuildItem mybatisBeanComponent(
+            List<SqlSessionFactoryBuildItem> sqlSessionFactoryBuildItem, CamelMyBatisRecorder recorder) {
+        return new CamelBeanBuildItem("mybatis-bean", MyBatisBeanComponent.class.getName(),
+                recorder.createMyBatisBeanComponent(sqlSessionFactoryBuildItem.get(0).getSqlSessionFactory()));

Review comment:
       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. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga merged pull request #2525: Fix #1384 camel-mybatis native support

Posted by GitBox <gi...@apache.org>.
ppalaga merged pull request #2525:
URL: https://github.com/apache/camel-quarkus/pull/2525


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org