Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning
titlePrefer MyBatis

The Apache iBatis project is no longer active. The project is moved outside Apache and is now know as the MyBatis project.
Therefore we encourage users to use MyBatis instead. This camel-ibatis component will be removed in Camel 3.0.

iBatis do not support Spring 4.x. So you can only use Spring 3.x or older with iBatis.

Maven users will need to add the following dependency to their pom.xml for this component:

Code Block
xml
xml

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-ibatis</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI format

Code Block

ibatis:statementName[?options]

...

For example if you wish to consume beans from a JMS queue and insert them into a database you could do the following:

Code Block

from("activemq:queue:newAccount").
  to("ibatis:insertAccount?statementType=Insert");

...

Where insertAccount is the iBatis ID in the SQL map file:

Code Block
xml
xml

  <!-- Insert example, using the Account parameter class -->
  <insert id="insertAccount" parameterClass="Account">
    insert into ACCOUNT (
      ACC_ID,
      ACC_FIRST_NAME,
      ACC_LAST_NAME,
      ACC_EMAIL
    )
    values (
      #id#, #firstName#, #lastName#, #emailAddress#
    )
  </insert>

...

In the sample below we poll the database, every 30 seconds using the Timer component and send the data to the JMS queue:

Code Block
java
java

from("timer://pollTheDatabase?delay=30000").to("ibatis:selectAllAccounts?statementType=QueryForList").to("activemq:queue:allAccounts");

And the iBatis SQL map file used:

Code Block
xml
xml

  <!-- Select with no parameters using the result map for Account class. -->
  <select id="selectAllAccounts" resultMap="AccountResult">
    select * from ACCOUNT
  </select>

...

Wiki Markup
{snippet:id=e2|lang=xml|url=camel/trunk/components/camel-ibatis/src/test/resources/org/apache/camel/component/ibatis/Account.xml}

Include Page
Endpoint See Also
Endpoint See Also