102.8. Samples
例如,如果要使用 JMS 队列中的 Bean 并将它们插入到数据库中,您可以执行以下操作:
from("activemq:queue:newAccount")
.to("mybatis:insertAccount?statementType=Insert");
您必须指定 statementType,因为您需要指示 Camel 要调用的操作类型。
其中 insertAccount 是 SQL 映射文件中的 MyBatis ID:
<!-- Insert example, using the Account parameter class -->
<insert id="insertAccount" parameterType="Account">
insert into ACCOUNT (
ACC_ID,
ACC_FIRST_NAME,
ACC_LAST_NAME,
ACC_EMAIL
)
values (
#{id}, #{firstName}, #{lastName}, #{emailAddress}
)
</insert>