Conflicts withl Date-timestamp Triggers and Mybatis Generator

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Conflicts withl Date-timestamp Triggers and Mybatis Generator

Daniel Needles
I might have missed the RTFM/link, so please redirect if so, but my Google Foo is failing me today.

I have a simple table with simple needs and date-timestamp triggers:

    CREATE TABLE IF NOT EXISTS `silly`.`table` (
      `real_data_field` VARCHAR(45) NOT NULL,
      PRIMARY KEY (`host_id`, `region`)) 

I generate via mvn mybatis-generator:generate but when the program runs, Mybatis clobbers the create_time and update_time to NULL.  It looks like there is an Ignore option available in the XML BUT I want to query with these field.   As a workaround I can commented out these fields for create_time and update_time in the XML insert and update functions, then the code worked fine.  But I'd rather not have to hack and rehack these autogenerated files every time.  Given I didn't find anything on this topic either way, I suspect I am missing something basic as I am new to Mybatis.  Could anyone provide any enlightenment?

Here's the XML for the Generator if it helps:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE generatorConfiguration
        PUBLIC "-// MyBatis Generator Configuration 1.0//EN"

      <classPathEntry location="/home/user/lib/mysql-connector-java-5.1.22.jar" />
      <context id="CTbls" targetRuntime="MyBatis3">
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/c"
                        userId="USER" password="PASS">
            <property name="nullCatalogMeansCurrent" value="true"/>

            <property name="forceBigDecimals" value="false"/>

        <!--  in command line environment  -->
        <javaModelGenerator targetPackage="com.nmsguru.c.deployservice.db.model" targetProject="/home/i2user/REPO/i2deploy/c/deploy-service/common/src/main/java">
            <property name="enableSubPackages" value="true" />
            <property name="trimStrings" value="true" />
        <sqlMapGenerator targetPackage="com.nmsguru.c.deployservice.db.xml"  targetProject="/home/i2user/REPO/i2deploy/c/deploy-service/common/src/main/java">
            <property name="enableSubPackages" value="true" />

        <javaClientGenerator type="XMLMAPPER" targetPackage="com.nmsguru.c.deployservice.db.mapper"  targetProject="/home/i2user/REPO/i2deploy/c/deploy-service/common/src/main/java">
            <property name="enableSubPackages" value="true" />

        <!--  in eclipse environment
       <javaModelGenerator targetPackage="com.nmsguru.c.deployservice.db.model" targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>

        <sqlMapGenerator targetPackage="com.nmsguru.c.deployservice.db.xml" targetProject="src/main/java">
            <property name="enableSubPackages" value="true"/>

        <javaClientGenerator type="XMLMAPPER" targetPackage="com.nmsguru.c.deployservice.db.mapper"
            <property name="enableSubPackages" value="true"/>
        <table schema="c" tableName="silly" domainObjectName="SillyBean">
          <generatedKey column="id" sqlStatement="MySql" identity="true" />

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