Open GoogleCodeExporter opened 9 years ago
This is the workaround I use in my POM. I'm posting it here in case anyone
needs it.
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>Post-process MyBatis Artifacts</id>
<phase>process-sources</phase>
<configuration>
<target name="process-mapper-xml" description="Fix the XML generated by MyBatis Generator">
<property name="daodir" location="src/gen/resources/com/mycompany/myproject/database/dao" />
<replace file="${daodir}/HoldingMapper.xml">
<replacetoken><![CDATA[id="insert" keyProperty="holdingId"]]></replacetoken>
<replacevalue><![CDATA[id="insert" keyColumn="HOLDING_ID" keyProperty="holdingId"]]></replacevalue>
</replace>
<replace file="${daodir}/HoldingMapper.xml">
<replacetoken><![CDATA[id="insertSelective" keyProperty="holdingId"]]></replacetoken>
<replacevalue><![CDATA[id="insertSelective" keyColumn="HOLDING_ID" keyProperty="holdingId"]]></replacevalue>
</replace>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Original comment by paulkrau...@alum.mit.edu
on 9 Oct 2012 at 3:06
Original comment by eduardo.macarron
on 13 Oct 2012 at 6:19
See this discussion thread:
https://groups.google.com/forum/?fromgroups=#!topic/mybatis-user/6vQ77_rT2lg
This issue has morphed into several things:
1. Add keyColumn attribute to the generated insert statement
2. Add code in the generator to guard against an identity column being the last
column in the table
3. Add the ability to specify multiple <generatedKey> elements for different
databases
Original comment by jeffgbut...@gmail.com
on 2 Nov 2012 at 2:17
Also, add keyColumn to any generated @Options
Original comment by jeffgbut...@gmail.com
on 10 Jan 2013 at 4:20
Original issue reported on code.google.com by
paulkrau...@alum.mit.edu
on 14 Sep 2012 at 10:06