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

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -