mybatis generator and GENERATED ALWAYS columns

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

mybatis generator and GENERATED ALWAYS columns

Ilko
Hi,

Is there any way to instruct the generator to exclude the GENERATED ALWAYS columns in the generated insert / update statements. The reason asking it is, that we are using the DB2 system history, which generates among the others two TIMESTAMP columns with GENERATED ALWAYS clause to track the changes. We need them in the selects, but it is not permitted to insert or update them - this causes DB2 to throw SQLCODE=-798. On the other side I think this is not only db2-specific topic because almost each rdbms has such a feature. I'm aware of the generated insertSelective statement, however in this case we have to set these properties to null prior to insert / update the db, which is error prone. How this scenario can be handled best?

Any suggestions are highly appreciated.

TIA,
Ilko

--
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
|

Re: mybatis generator and GENERATED ALWAYS columns

Jeff Butler
If the columns are a part of the key, you could use the <generatedKey> configuration element to list the columns.  Then the generator would not include those columns in the inserts or updates.

If they are not part of the key, then there's no way currently to configure the generator to ignore them on inserts and updates.  If you need that support, then please feel free to open an issue at GitHub and I'll see what I can do to add that support.

Jeff Butler


On Tue, Jun 28, 2016 at 9:54 AM Ilko <[hidden email]> wrote:
Hi,

Is there any way to instruct the generator to exclude the GENERATED ALWAYS columns in the generated insert / update statements. The reason asking it is, that we are using the DB2 system history, which generates among the others two TIMESTAMP columns with GENERATED ALWAYS clause to track the changes. We need them in the selects, but it is not permitted to insert or update them - this causes DB2 to throw SQLCODE=-798. On the other side I think this is not only db2-specific topic because almost each rdbms has such a feature. I'm aware of the generated insertSelective statement, however in this case we have to set these properties to null prior to insert / update the db, which is error prone. How this scenario can be handled best?

Any suggestions are highly appreciated.

TIA,
Ilko

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis generator and GENERATED ALWAYS columns

Ilko
unfortunately, they are not part of the key. I've submitted a RFE on github:

https://github.com/mybatis/generator/issues/104

Thanks,
Ilko

On Tuesday, June 28, 2016 at 8:23:31 PM UTC+2, Jeff Butler wrote:
If the columns are a part of the key, you could use the <generatedKey> configuration element to list the columns.  Then the generator would not include those columns in the inserts or updates.

If they are not part of the key, then there's no way currently to configure the generator to ignore them on inserts and updates.  If you need that support, then please feel free to open an issue at GitHub and I'll see what I can do to add that support.

Jeff Butler


On Tue, Jun 28, 2016 at 9:54 AM Ilko <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="_cjCc0DECQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ilkom...@...> wrote:
Hi,

Is there any way to instruct the generator to exclude the GENERATED ALWAYS columns in the generated insert / update statements. The reason asking it is, that we are using the DB2 system history, which generates among the others two TIMESTAMP columns with GENERATED ALWAYS clause to track the changes. We need them in the selects, but it is not permitted to insert or update them - this causes DB2 to throw SQLCODE=-798. On the other side I think this is not only db2-specific topic because almost each rdbms has such a feature. I'm aware of the generated insertSelective statement, however in this case we have to set these properties to null prior to insert / update the db, which is error prone. How this scenario can be handled best?

Any suggestions are highly appreciated.

TIA,
Ilko

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="_cjCc0DECQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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.