MyBatis Generator: Custom SQL in Generated Update Queries, possible or new plugin?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

MyBatis Generator: Custom SQL in Generated Update Queries, possible or new plugin?

f-aubert
Hello,
I'm new to this list and would welcome any help on a specific use case.
I'm using MyBatis Generator to generate my SqlMap, and Java Objects. I wished I could, for every update (in particular updateByPrimaryKeySelective), add one or more custom sql expression in order in my case to increment my VERSION column by one (SET VERSION = VERSION + 1), or possibly set the MUTATION_DATE to now (SET MUTATION_DATE = now()).
It can be hard coded pretty easily in each generated SqlMap but it will be lost each time I go through the Generator. Did I miss a solution, or should I ask for a new and simple Plugin?
Best regards,
Frederic

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MyBatis Generator: Custom SQL in Generated Update Queries, possible or new plugin?

Jeff Butler
You would need to write a plugin to do that.  Unfortunately, it's probably a moderately complex plugin as you would need to parse the generated SQL to find where to make your changes.

Jeff Butler



On Tue, Mar 7, 2017 at 2:20 AM f-aubert <[hidden email]> wrote:
Hello,
I'm new to this list and would welcome any help on a specific use case.
I'm using MyBatis Generator to generate my SqlMap, and Java Objects. I wished I could, for every update (in particular updateByPrimaryKeySelective), add one or more custom sql expression in order in my case to increment my VERSION column by one (SET VERSION = VERSION + 1), or possibly set the MUTATION_DATE to now (SET MUTATION_DATE = now()).
It can be hard coded pretty easily in each generated SqlMap but it will be lost each time I go through the Generator. Did I miss a solution, or should I ask for a new and simple Plugin?
Best regards,
Frederic

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...