Versions Compared

Key

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

...

Code Block
<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>

h3. 

URI

...

format

Code Block


ibatis:statementName[?options]
Code Block

Where

...

statementName

...

is

...

the

...

name

...

in

...

the

...

iBATIS

...

XML

...

configuration

...

file

...

which

...

maps

...

to

...

the

...

query,

...

insert,

...

update

...

or

...

delete

...

operation

...

you

...

wish

...

to

...

evaluate.

...

You

...

can

...

append

...

query

...

options

...

to

...

the

...

URI

...

in

...

the

...

following

...

format,

...

?option=value&option=value&...

...

This

...

component

...

will

...

by

...

default

...

load

...

the

...

iBatis

...

SqlMapConfig

...

file

...

from

...

the

...

root

...

of

...

the

...

classpath

...

and

...

expected

...

named

...

as

...

SqlMapConfig.xml

...

.

...


It

...

uses

...

Spring

...

resource

...

loading

...

so

...

you

...

can

...

define

...

it

...

using

...

classpath

...

,

...

file

...

or

...

http

...

as

...

prefix

...

to

...

load

...

resources

...

with

...

those

...

schemes.

...


In

...

Camel

...

2.2

...

you

...

can

...

configure

...

this

...

on

...

the

...

iBatisComponent

...

with

...

the

...

setSqlMapConfig(String)

...

method.

...

Options

Option

Type

Default

Description

consumer.onConsume

String

null

Statements to run after consuming. Can be used, for example, to update rows after they have been consumed and processed in Camel. See sample later. Multiple statements can be separated with comma.

consumer.useIterator

boolean

true

If true each row returned when polling will be processed individually. If false the entire List of data is set as the IN body.

consumer.routeEmptyResultSet

boolean

false

Camel 2.0: Sets whether empty result set should be routed or not. By default, empty result sets are not routed.

statementType

StatementType

null

Camel 1.6.1/2.0:

...

Mandatory

...

to

...

specify

...

for

...

IbatisProducer

...

to

...

control

...

which

...

iBatis

...

SqlMapClient

...

method

...

to

...

invoke.

...

The

...

enum

...

values

...

are:

...

QueryForObject

...

,

...

QueryForList

...

,

...

Insert

...

,

...

Update

...

,

...

Delete

...

.

maxMessagesPerPoll

int

0

Camel 2.0:

...

An

...

integer

...

to

...

define

...

a

...

maximum

...

messages

...

to

...

gather

...

per

...

poll.

...

By

...

default,

...

no

...

maximum

...

is

...

set.

...

Can

...

be

...

used

...

to

...

set

...

a

...

limit

...

of

...

e.g.

...

1000

...

to

...

avoid

...

when

...

starting

...

up

...

the

...

server

...

that

...

there

...

are

...

thousands

...

of

...

files.

...

Set

...

a

...

value

...

of

...

0

...

or

...

negative

...

to

...

disabled

...

it.

...

Message Headers

Camel will populate the result message, either IN or OUT with a header with the operationName used:

Header

Type

Description

org.apache.camel.ibatis.queryName

...

String

Camel 1.x:

...

The

...

statementName

...

used

...

(for

...

example:

...

insertAccount).

...

CamelIBatisStatementName

String

Camel 2.0:

...

The

...

statementName

...

used

...

(for

...

example:

...

insertAccount).

...

CamelIBatisResult

Object

Camel 1.6.2/2.0:

...

The

...

response

...

returned

...

from

...

iBatis

...

in

...

any

...

of

...

the

...

operations.

...

For

...

instance

...

an

...

INSERT

...

could

...

return

...

the

...

auto-generated

...

key,

...

or

...

number

...

of

...

rows

...

etc.

...

Message Body

Camel 1.6.1

...

:

...

The

...

response

...

from

...

iBatis

...

will

...

be

...

set

...

as

...

OUT

...

body

...


Camel

...

1.6.2/2.0

...

:

...

The

...

response

...

from

...

iBatis

...

will

...

only

...

be

...

set

...

as

...

body

...

if

...

it's

...

a

...

SELECT

...

statement.

...

That

...

means,

...

for

...

example,

...

for

...

INSERT

...

statements

...

Camel

...

will

...

not

...

replace

...

the

...

body.

...

This

...

allows

...

you

...

to

...

continue

...

routing

...

and

...

keep

...

the

...

original

...

body.

...

The

...

response

...

from

...

iBatis

...

is

...

always

...

stored

...

in

...

the

...

header

...

with

...

the

...

key

...

CamelIBatisResult.

Samples

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

}}.

h3. Samples

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

from("activemq:queue:newAccount").

...


  to("ibatis:insertAccount?statementType=Insert");
Code Block

Notice

...

we

...

have

...

to

...

specify

...

the

...

statementType

...

,

...

as

...

we

...

need

...

to

...

instruct

...

Camel

...

which

...

SqlMapClient

...

operation

...

to

...

invoke.

...

Where

...

insertAccount

...

is

...

the

...

iBatis

...

ID

...

in

...

the

...

SQL

...

map

...

file:

Code Block
xml
xml

{code: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>

...