235.5. サンプル
たとえば、JMS キューから Bean を消費してデータベースに挿入する場合は、次のようにします。
from("activemq:queue:newAccount")
.to("mybatis-bean:AccountService:insertBeanAccount");
from("activemq:queue:newAccount")
.to("mybatis-bean:AccountService:insertBeanAccount");
呼び出す操作の種類を Camel に指示する必要があるため、Bean 名とメソッド名を指定する必要があることに注意してください。
AccountService は、MyBatis Bean アノテーションを持つ Bean のタイプエイリアスです。SqlMapConfig ファイルでタイプエイリアスを設定できます。
<typeAliases>
<typeAlias alias="Account" type="org.apache.camel.component.mybatis.Account"/>
<typeAlias alias="AccountService" type="org.apache.camel.component.mybatis.bean.AccountService"/>
</typeAliases>
<typeAliases>
<typeAlias alias="Account" type="org.apache.camel.component.mybatis.Account"/>
<typeAlias alias="AccountService" type="org.apache.camel.component.mybatis.bean.AccountService"/>
</typeAliases>
On the `AccountService` bean you can declare the MyBatis mappins using annotations as shown:
On the `AccountService` bean you can declare the MyBatis mappins using annotations as shown: