Search code examples
firebirdmybatisfirebird2.5ibator

Read-only column mapped using MyBatis Generator


Firebird database supports read-only columns. Columns that have their values computed, not updated. If I map some table with read-only columns using MyBatis Generator I receive the following error while inserting into or updating the table:

org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544359. attempted update of read-only column.

How to treat this kind of column using MyBatis Generator? Is it possible to have insert and update statements ignoring this kind of column?

Note: Using insertSelective and updateSelective passing the read-only columns values as null, instead of using insert and update, will solve only the cases where I don't want to update other fields to null. So, I need another solution.


Solution

  • MyBatis does not offer additional support to read-only columns. So, the turnaround solution is to set the read only columns with the ignoreColumn tag and to write the queries that need that column value manually, using @Select annotations in mappers.

    <table tableName="...">
        ...
        <ignoreColumn column="<read only column>" /> 
        ...
    </table>