Hi everyone.

I'm using MyBatis Generator to generate our MyBatis artifacts and the mapper 
files contain id= attributes that are very generic. For example, insert is 
what's used as the id for an insert statement instead of something like, 
insertObjectName. Our code running outside of Camel doesn't really have any 
difficulty with these ambiguous names, however, trying to execute an insert 
under Camel I get exceptions from MyBatis complaining about the ambiguous 
nature:

"### Error updating database. Cause: java.lang.IllegalArgumentException: insert 
is ambiguous in Mapped Statements collection (try using the full name including 
the namespace, or rename one of the entries)
### Cause: java.lang.IllegalArgumentException: insert is ambiguous in Mapped 
Statements collection (try using the full name including the namespace, or 
rename one of the entries)"

I realize the simple answer is to make the id= attributes specific, but these 
are generated by MyBatis generator, and I don't want to create a maintenance 
nightmare having to rename id= attributes after each MBG run. For example here 
is an MBG generated insert (names changed/made generic for privacy):


<insert id="insertObjectName" 
parameterType="com.workplace.staging.data.domain.ObjectName" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not 
modify.
      This element was generated on Wed Mar 25 18:26:28 EDT 2015.
    -->
    <selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
      jdbc
    </selectKey>
    insert into staging.object_name (field1, field2, field3,
      field4, field5, field6)
    values (#{field1,jdbcType=VARCHAR}, #{field2,jdbcType=VARCHAR}, 
#{field3,jdbcType=VARCHAR},
      #{field4,jdbcType=VARCHAR}, #{field5,jdbcType=DATE}, 
#{field6,jdbcType=DATE})
  </insert>


Does anyone have any suggestions or tips for a workflow using MyBatis generator 
in a Camel-MyBatis solution? My only thought is to build a custom MBG plugin to 
handle maintaining our Bindy mappings, as well as making the generation of the 
id= attributes more specific. Unfortunately using our MBG generated model, the 
Bindy annotations will get wiped out every time the MBG model is generated.

I hope I explained all of that well. Thanks for any input you all might have on 
this.

Daniel

Reply via email to