mybatis - How can I reuse an SQL fragment with parameters? -



mybatis - How can I reuse an SQL fragment with parameters? -

i'm intending create fragment reusing parameters.

class="lang-xml prettyprint-override"><insert ...> <selectkey keyproperty="id" resulttype="_long" order="before"> <choose> <when test="_databaseid == 'derby'"> values next value some_id_seq </when> <otherwise> select some_id_seq.nextval dual </otherwise> </choose> </selectkey> insert ... </insert>

can create sql fragment using parameters?

class="lang-xml prettyprint-override"><sql id="selectkeyfromsequence"> <selectkey keyproperty="id" resulttype="_long" order="before"> <choose> <when test="_databaseid == 'derby'"> values next value #{sequencename} </when> <otherwise> select #{sequencename}.nextval dual </otherwise> </choose> </selectkey> </sql>

so can reuse them this?

class="lang-xml prettyprint-override"><insert ...> <include refid="...selectkeyfromsequence"/> <!-- how can pass parameter? --> insert ... </insert>

is possible?

you cannot pass parameter tags. there similar so question, ibatis issue , mybatis issue.

includes in-lined when xmls parsed not exist own 1 time startup process finishes (from mybatis issue).

however, can utilize variables within tags. not pass parameter can give parameter function has include tag. need utilize same variable name in functions, i.e. #{sequencename}.

mybatis ibatis

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -