MyBatis Generator "methodNameCalculator" property seems to be ignored.

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

MyBatis Generator "methodNameCalculator" property seems to be ignored.

Maximiliano Juárez Ramos
Hi,

I'm using MyBatis Generator for Eclipse 1.3.1 and according to the User's Guide, the <javaClientGenerator> has a property "methodNameCalculator" that when its value is:

"extended" ---- The generated method names will include the name of the domain object associated with the method ("insertWidget", "updateWidgetByPrimaryKey", etc.)

But, the methods always are generated as "insert", "updateByPrimaryKey", etc.

Besides that, generator works fine, no exceptions, no errors. Any help would be appreciated.

Thanks

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration >
    <properties resource="database.properties"/>
    <classPathEntry location="/PF/jlibs/hsqldb-2.0.0/lib/hsqldb.jar"/>
    <context
        id="default"
        targetRuntime="MyBatis3">
        <jdbcConnection
            driverClass="${driver}"
            connectionURL="${url}"
            userId="${username}"
            password="${password}" />
        <javaModelGenerator
            targetPackage="juarezmax.demo.mybatis.domain"
            targetProject="demo.mybatis/src/main/java">
        </javaModelGenerator>
        <sqlMapGenerator
            targetPackage="juarezmax.demo.mybatis.mappers"
            targetProject="demo.mybatis/src/main/java" />
        <javaClientGenerator
            targetPackage="juarezmax.demo.mybatis.mappers"
            targetProject="demo.mybatis/src/main/java"
            type="ANNOTATEDMAPPER">
            <property name="methodNameCalculator" value="extended" />
        </javaClientGenerator>
        <table
            tableName="vehiculos"
            domainObjectName="Vehiculo">
            <generatedKey
                column="id"
                sqlStatement="HSQLDB"
                identity="true"/>
        </table>
    </context>
</generatorConfiguration>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MyBatis Generator "methodNameCalculator" property seems to be ignored.

Jeff Butler
That property is ignored when MyBatis3 is the target.  I'll add that
to the documentation.

Jeff Butler


2011/1/26 Maximiliano Juárez Ramos <[hidden email]>:

> Hi,
>
> I'm using MyBatis Generator for Eclipse 1.3.1 and according to the User's
> Guide, the <javaClientGenerator> has a property "methodNameCalculator" that
> when its value is:
>
> "extended" ---- The generated method names will include the name of the
> domain object associated with the method ("insertWidget",
> "updateWidgetByPrimaryKey", etc.)
>
> But, the methods always are generated as "insert", "updateByPrimaryKey",
> etc.
>
> Besides that, generator works fine, no exceptions, no errors. Any help would
> be appreciated.
>
> Thanks
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis
> Generator Configuration 1.0//EN"
> "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
> <generatorConfiguration >
>     <properties resource="database.properties"/>
>     <classPathEntry location="/PF/jlibs/hsqldb-2.0.0/lib/hsqldb.jar"/>
>     <context
>         id="default"
>         targetRuntime="MyBatis3">
>         <jdbcConnection
>             driverClass="${driver}"
>             connectionURL="${url}"
>             userId="${username}"
>             password="${password}" />
>         <javaModelGenerator
>             targetPackage="juarezmax.demo.mybatis.domain"
>             targetProject="demo.mybatis/src/main/java">
>         </javaModelGenerator>
>         <sqlMapGenerator
>             targetPackage="juarezmax.demo.mybatis.mappers"
>             targetProject="demo.mybatis/src/main/java" />
>         <javaClientGenerator
>             targetPackage="juarezmax.demo.mybatis.mappers"
>             targetProject="demo.mybatis/src/main/java"
>             type="ANNOTATEDMAPPER">
>             <property name="methodNameCalculator" value="extended" />
>         </javaClientGenerator>
>         <table
>             tableName="vehiculos"
>             domainObjectName="Vehiculo">
>             <generatedKey
>                 column="id"
>                 sqlStatement="HSQLDB"
>                 identity="true"/>
>         </table>
>     </context>
> </generatorConfiguration>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MyBatis Generator "methodNameCalculator" property seems to be ignored.

Paulo Soares
Why?


On 27 jan, 00:32, Jeff Butler <[hidden email]> wrote:

> That property is ignored when MyBatis3 is the target.  I'll add that
> to the documentation.
>
> Jeff Butler
>
> 2011/1/26 Maximiliano Juárez Ramos <[hidden email]>:
>
>
>
>
>
>
>
> > Hi,
>
> > I'm using MyBatis Generator for Eclipse 1.3.1 and according to the User's
> > Guide, the <javaClientGenerator> has a property "methodNameCalculator" that
> > when its value is:
>
> > "extended" ---- The generated method names will include the name of the
> > domain object associated with the method ("insertWidget",
> > "updateWidgetByPrimaryKey", etc.)
>
> > But, the methods always are generated as "insert", "updateByPrimaryKey",
> > etc.
>
> > Besides that, generator works fine, no exceptions, no errors. Any help would
> > be appreciated.
>
> > Thanks
>
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis
> > Generator Configuration 1.0//EN"
> > "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
> > <generatorConfiguration >
> >     <properties resource="database.properties"/>
> >     <classPathEntry location="/PF/jlibs/hsqldb-2.0.0/lib/hsqldb.jar"/>
> >     <context
> >         id="default"
> >         targetRuntime="MyBatis3">
> >         <jdbcConnection
> >             driverClass="${driver}"
> >             connectionURL="${url}"
> >             userId="${username}"
> >             password="${password}" />
> >         <javaModelGenerator
> >             targetPackage="juarezmax.demo.mybatis.domain"
> >             targetProject="demo.mybatis/src/main/java">
> >         </javaModelGenerator>
> >         <sqlMapGenerator
> >             targetPackage="juarezmax.demo.mybatis.mappers"
> >             targetProject="demo.mybatis/src/main/java" />
> >         <javaClientGenerator
> >             targetPackage="juarezmax.demo.mybatis.mappers"
> >             targetProject="demo.mybatis/src/main/java"
> >             type="ANNOTATEDMAPPER">
> >             <property name="methodNameCalculator" value="extended" />
> >         </javaClientGenerator>
> >         <table
> >             tableName="vehiculos"
> >             domainObjectName="Vehiculo">
> >             <generatedKey
> >                 column="id"
> >                 sqlStatement="HSQLDB"
> >                 identity="true"/>
> >         </table>
> >     </context>
> > </generatorConfiguration>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MyBatis Generator "methodNameCalculator" property seems to be ignored.

Jeff Butler
Because there are no longer DAO's with MyBatis3 - the Java mapper
names must match the IDs in the XML.  With iBATIS2 the DAO method
names did not need to match the IDs in XML.

If you feel you must change the names, you can do it with a plugin.

Jeff Butler

On Wed, Feb 23, 2011 at 10:19 PM, Paulo Soares <[hidden email]> wrote:

> Why?
>
>
> On 27 jan, 00:32, Jeff Butler <[hidden email]> wrote:
>> That property is ignored when MyBatis3 is the target.  I'll add that
>> to the documentation.
>>
>> Jeff Butler
>>
>> 2011/1/26 Maximiliano Juárez Ramos <[hidden email]>:
>>
>>
>>
>>
>>
>>
>>
>> > Hi,
>>
>> > I'm using MyBatis Generator for Eclipse 1.3.1 and according to the User's
>> > Guide, the <javaClientGenerator> has a property "methodNameCalculator" that
>> > when its value is:
>>
>> > "extended" ---- The generated method names will include the name of the
>> > domain object associated with the method ("insertWidget",
>> > "updateWidgetByPrimaryKey", etc.)
>>
>> > But, the methods always are generated as "insert", "updateByPrimaryKey",
>> > etc.
>>
>> > Besides that, generator works fine, no exceptions, no errors. Any help would
>> > be appreciated.
>>
>> > Thanks
>>
>> > <?xml version="1.0" encoding="UTF-8" ?>
>> > <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis
>> > Generator Configuration 1.0//EN"
>> > "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
>> > <generatorConfiguration >
>> >     <properties resource="database.properties"/>
>> >     <classPathEntry location="/PF/jlibs/hsqldb-2.0.0/lib/hsqldb.jar"/>
>> >     <context
>> >         id="default"
>> >         targetRuntime="MyBatis3">
>> >         <jdbcConnection
>> >             driverClass="${driver}"
>> >             connectionURL="${url}"
>> >             userId="${username}"
>> >             password="${password}" />
>> >         <javaModelGenerator
>> >             targetPackage="juarezmax.demo.mybatis.domain"
>> >             targetProject="demo.mybatis/src/main/java">
>> >         </javaModelGenerator>
>> >         <sqlMapGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java" />
>> >         <javaClientGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java"
>> >             type="ANNOTATEDMAPPER">
>> >             <property name="methodNameCalculator" value="extended" />
>> >         </javaClientGenerator>
>> >         <table
>> >             tableName="vehiculos"
>> >             domainObjectName="Vehiculo">
>> >             <generatedKey
>> >                 column="id"
>> >                 sqlStatement="HSQLDB"
>> >                 identity="true"/>
>> >         </table>
>> >     </context>
>> > </generatorConfiguration>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MyBatis Generator "methodNameCalculator" property seems to be ignored.

myvideoex
Hi Jeff, I want to customize the generated method named, but I didn't find any plugin to do this task, have I missed something or should I write a new plugin for this task?

On Thursday, February 24, 2011 at 11:07:06 PM UTC+8, Jeff Butler wrote:
Because there are no longer DAO's with MyBatis3 - the Java mapper
names must match the IDs in the XML.  With iBATIS2 the DAO method
names did not need to match the IDs in XML.

If you feel you must change the names, you can do it with a plugin.

Jeff Butler

On Wed, Feb 23, 2011 at 10:19 PM, Paulo Soares <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="TNX7dtKilOEJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">paulo...@...> wrote:


> Why?
>
>
> On 27 jan, 00:32, Jeff Butler <[hidden email]> wrote:
>> That property is ignored when MyBatis3 is the target.  I'll add that
>> to the documentation.
>>
>> Jeff Butler
>>
>> 2011/1/26 Maximiliano Juárez Ramos <[hidden email]>:
>>
>>
>>
>>
>>
>>
>>
>> > Hi,
>>
>> > I'm using MyBatis Generator for Eclipse 1.3.1 and according to the User's
>> > Guide, the <javaClientGenerator> has a property "methodNameCalculator" that
>> > when its value is:
>>
>> > "extended" ---- The generated method names will include the name of the
>> > domain object associated with the method ("insertWidget",
>> > "updateWidgetByPrimaryKey", etc.)
>>
>> > But, the methods always are generated as "insert", "updateByPrimaryKey",
>> > etc.
>>
>> > Besides that, generator works fine, no exceptions, no errors. Any help would
>> > be appreciated.
>>
>> > Thanks
>>
>> > <?xml version="1.0" encoding="UTF-8" ?>
>> > <!DOCTYPE generatorConfiguration PUBLIC "-//<a href="http://mybatis.org//DTD" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2F%2FDTD\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHjp-E8UL0TmmS7A0V54yMfbtfEkA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2F%2FDTD\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHjp-E8UL0TmmS7A0V54yMfbtfEkA&#39;;return true;">mybatis.org//DTD MyBatis
>> > Generator Configuration 1.0//EN"
>> > "<a href="http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2Fdtd%2Fmybatis-generator-config_1_0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGbQhQcAyMHnIvI65x3b69_l8vDOQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2Fdtd%2Fmybatis-generator-config_1_0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGbQhQcAyMHnIvI65x3b69_l8vDOQ&#39;;return true;">http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
>> > <generatorConfiguration >
>> >     <properties resource="database.properties"/>
>> >     <classPathEntry location="/PF/jlibs/hsqldb-2.0.0/lib/hsqldb.jar"/>
>> >     <context
>> >         id="default"
>> >         targetRuntime="MyBatis3">
>> >         <jdbcConnection
>> >             driverClass="${driver}"
>> >             connectionURL="${url}"
>> >             userId="${username}"
>> >             password="${password}" />
>> >         <javaModelGenerator
>> >             targetPackage="juarezmax.demo.mybatis.domain"
>> >             targetProject="demo.mybatis/src/main/java">
>> >         </javaModelGenerator>
>> >         <sqlMapGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java" />
>> >         <javaClientGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java"
>> >             type="ANNOTATEDMAPPER">
>> >             <property name="methodNameCalculator" value="extended" />
>> >         </javaClientGenerator>
>> >         <table
>> >             tableName="vehiculos"
>> >             domainObjectName="Vehiculo">
>> >             <generatedKey
>> >                 column="id"
>> >                 sqlStatement="HSQLDB"
>> >                 identity="true"/>
>> >         </table>
>> >     </context>
>> > </generatorConfiguration>

--
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 "methodNameCalculator" property seems to be ignored.

Jeff Butler
I'm not aware of any plugin already existing for this so you would need to write a new one. In your plugin, override the initialized(IntrospectedTable) method and then call methods like IntrospectedTable.setInsertStatementId" and IntrospectedTable.setDeleteByPrimaryKeyStatementId.

Jeff Butler


On Mon, Apr 24, 2017 at 9:50 AM <[hidden email]> wrote:
Hi Jeff, I want to customize the generated method named, but I didn't find any plugin to do this task, have I missed something or should I write a new plugin for this task?


On Thursday, February 24, 2011 at 11:07:06 PM UTC+8, Jeff Butler wrote:
Because there are no longer DAO's with MyBatis3 - the Java mapper
names must match the IDs in the XML.  With iBATIS2 the DAO method
names did not need to match the IDs in XML.

If you feel you must change the names, you can do it with a plugin.

Jeff Butler

On Wed, Feb 23, 2011 at 10:19 PM, Paulo Soares <[hidden email]> wrote:


> Why?
>
>
> On 27 jan, 00:32, Jeff Butler <[hidden email]> wrote:
>> That property is ignored when MyBatis3 is the target.  I'll add that
>> to the documentation.
>>
>> Jeff Butler
>>
>> 2011/1/26 Maximiliano Juárez Ramos <[hidden email]>:
>>
>>
>>
>>
>>
>>
>>
>> > Hi,
>>
>> > I'm using MyBatis Generator for Eclipse 1.3.1 and according to the User's
>> > Guide, the <javaClientGenerator> has a property "methodNameCalculator" that
>> > when its value is:
>>
>> > "extended" ---- The generated method names will include the name of the
>> > domain object associated with the method ("insertWidget",
>> > "updateWidgetByPrimaryKey", etc.)
>>
>> > But, the methods always are generated as "insert", "updateByPrimaryKey",
>> > etc.
>>
>> > Besides that, generator works fine, no exceptions, no errors. Any help would
>> > be appreciated.
>>
>> > Thanks
>>
>> > <?xml version="1.0" encoding="UTF-8" ?>
>> > <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis
>> > Generator Configuration 1.0//EN"
>> > "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
>> > <generatorConfiguration >
>> >     <properties resource="database.properties"/>
>> >     <classPathEntry location="/PF/jlibs/hsqldb-2.0.0/lib/hsqldb.jar"/>
>> >     <context
>> >         id="default"
>> >         targetRuntime="MyBatis3">
>> >         <jdbcConnection
>> >             driverClass="${driver}"
>> >             connectionURL="${url}"
>> >             userId="${username}"
>> >             password="${password}" />
>> >         <javaModelGenerator
>> >             targetPackage="juarezmax.demo.mybatis.domain"
>> >             targetProject="demo.mybatis/src/main/java">
>> >         </javaModelGenerator>
>> >         <sqlMapGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java" />
>> >         <javaClientGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java"
>> >             type="ANNOTATEDMAPPER">
>> >             <property name="methodNameCalculator" value="extended" />
>> >         </javaClientGenerator>
>> >         <table
>> >             tableName="vehiculos"
>> >             domainObjectName="Vehiculo">
>> >             <generatedKey
>> >                 column="id"
>> >                 sqlStatement="HSQLDB"
>> >                 identity="true"/>
>> >         </table>
>> >     </context>
>> > </generatorConfiguration>

--
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
|  
Report Content as Inappropriate

Re: MyBatis Generator "methodNameCalculator" property seems to be ignored.

myvideoex
Thank you for your advice. I write a simple plugin with your advice, now I can change method names, and I can also disable some methods. 
I did some investigation, and find that the displaying sequence was controlled in SimpleJavaClientGenerator.getCompilationUnits,maybe I can change sequence or add other method in this method.
I wonder whether I can control the displaying sequence of those methods and whether I can add my custom method&sqlmap to mapper class&xml file within customized plugin or by extending generator? 

On Monday, April 24, 2017 at 10:54:45 PM UTC+8, Jeff Butler wrote:
I'm not aware of any plugin already existing for this so you would need to write a new one. In your plugin, override the initialized(IntrospectedTable) method and then call methods like IntrospectedTable.setInsertStatementId" and IntrospectedTable.setDeleteByPrimaryKeyStatementId.

Jeff Butler


On Mon, Apr 24, 2017 at 9:50 AM <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="6q8hpN5VAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">myvi...@...> wrote:
Hi Jeff, I want to customize the generated method named, but I didn't find any plugin to do this task, have I missed something or should I write a new plugin for this task?


On Thursday, February 24, 2011 at 11:07:06 PM UTC+8, Jeff Butler wrote:
Because there are no longer DAO's with MyBatis3 - the Java mapper
names must match the IDs in the XML.  With iBATIS2 the DAO method
names did not need to match the IDs in XML.

If you feel you must change the names, you can do it with a plugin.

Jeff Butler

On Wed, Feb 23, 2011 at 10:19 PM, Paulo Soares <[hidden email]> wrote:


> Why?
>
>
> On 27 jan, 00:32, Jeff Butler <[hidden email]> wrote:
>> That property is ignored when MyBatis3 is the target.  I'll add that
>> to the documentation.
>>
>> Jeff Butler
>>
>> 2011/1/26 Maximiliano Juárez Ramos <[hidden email]>:
>>
>>
>>
>>
>>
>>
>>
>> > Hi,
>>
>> > I'm using MyBatis Generator for Eclipse 1.3.1 and according to the User's
>> > Guide, the <javaClientGenerator> has a property "methodNameCalculator" that
>> > when its value is:
>>
>> > "extended" ---- The generated method names will include the name of the
>> > domain object associated with the method ("insertWidget",
>> > "updateWidgetByPrimaryKey", etc.)
>>
>> > But, the methods always are generated as "insert", "updateByPrimaryKey",
>> > etc.
>>
>> > Besides that, generator works fine, no exceptions, no errors. Any help would
>> > be appreciated.
>>
>> > Thanks
>>
>> > <?xml version="1.0" encoding="UTF-8" ?>
>> > <!DOCTYPE generatorConfiguration PUBLIC "-//<a href="http://mybatis.org//DTD" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2F%2FDTD\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHjp-E8UL0TmmS7A0V54yMfbtfEkA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2F%2FDTD\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHjp-E8UL0TmmS7A0V54yMfbtfEkA&#39;;return true;">mybatis.org//DTD MyBatis
>> > Generator Configuration 1.0//EN"
>> > "<a href="http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2Fdtd%2Fmybatis-generator-config_1_0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGbQhQcAyMHnIvI65x3b69_l8vDOQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2Fdtd%2Fmybatis-generator-config_1_0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGbQhQcAyMHnIvI65x3b69_l8vDOQ&#39;;return true;">http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
>> > <generatorConfiguration >
>> >     <properties resource="database.properties"/>
>> >     <classPathEntry location="/PF/jlibs/hsqldb-2.0.0/lib/hsqldb.jar"/>
>> >     <context
>> >         id="default"
>> >         targetRuntime="MyBatis3">
>> >         <jdbcConnection
>> >             driverClass="${driver}"
>> >             connectionURL="${url}"
>> >             userId="${username}"
>> >             password="${password}" />
>> >         <javaModelGenerator
>> >             targetPackage="juarezmax.demo.mybatis.domain"
>> >             targetProject="demo.mybatis/src/main/java">
>> >         </javaModelGenerator>
>> >         <sqlMapGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java" />
>> >         <javaClientGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java"
>> >             type="ANNOTATEDMAPPER">
>> >             <property name="methodNameCalculator" value="extended" />
>> >         </javaClientGenerator>
>> >         <table
>> >             tableName="vehiculos"
>> >             domainObjectName="Vehiculo">
>> >             <generatedKey
>> >                 column="id"
>> >                 sqlStatement="HSQLDB"
>> >                 identity="true"/>
>> >         </table>
>> >     </context>
>> > </generatorConfiguration>

--
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="6q8hpN5VAwAJ" 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MyBatis Generator "methodNameCalculator" property seems to be ignored.

Jeff Butler
In your plugin you can override the sqlMapGenerated() and clientGenerated() methods to add more mapper methods and the corresponding XML.

If you want to change the order of methods in the generated code, then in the configuration, you can specify your own custom type for the JavaClientGenerator.  Then you can have total control over how the methods get generated.

Jeff Butler




On Tue, Apr 25, 2017 at 10:27 AM <[hidden email]> wrote:
Thank you for your advice. I write a simple plugin with your advice, now I can change method names, and I can also disable some methods. 
I did some investigation, and find that the displaying sequence was controlled in SimpleJavaClientGenerator.getCompilationUnits,maybe I can change sequence or add other method in this method.
I wonder whether I can control the displaying sequence of those methods and whether I can add my custom method&sqlmap to mapper class&xml file within customized plugin or by extending generator? 


On Monday, April 24, 2017 at 10:54:45 PM UTC+8, Jeff Butler wrote:
I'm not aware of any plugin already existing for this so you would need to write a new one. In your plugin, override the initialized(IntrospectedTable) method and then call methods like IntrospectedTable.setInsertStatementId" and IntrospectedTable.setDeleteByPrimaryKeyStatementId.

Jeff Butler


On Mon, Apr 24, 2017 at 9:50 AM <[hidden email]> wrote:
Hi Jeff, I want to customize the generated method named, but I didn't find any plugin to do this task, have I missed something or should I write a new plugin for this task?


On Thursday, February 24, 2011 at 11:07:06 PM UTC+8, Jeff Butler wrote:
Because there are no longer DAO's with MyBatis3 - the Java mapper
names must match the IDs in the XML.  With iBATIS2 the DAO method
names did not need to match the IDs in XML.

If you feel you must change the names, you can do it with a plugin.

Jeff Butler

On Wed, Feb 23, 2011 at 10:19 PM, Paulo Soares <[hidden email]> wrote:


> Why?
>
>
> On 27 jan, 00:32, Jeff Butler <[hidden email]> wrote:
>> That property is ignored when MyBatis3 is the target.  I'll add that
>> to the documentation.
>>
>> Jeff Butler
>>
>> 2011/1/26 Maximiliano Juárez Ramos <[hidden email]>:
>>
>>
>>
>>
>>
>>
>>
>> > Hi,
>>
>> > I'm using MyBatis Generator for Eclipse 1.3.1 and according to the User's
>> > Guide, the <javaClientGenerator> has a property "methodNameCalculator" that
>> > when its value is:
>>
>> > "extended" ---- The generated method names will include the name of the
>> > domain object associated with the method ("insertWidget",
>> > "updateWidgetByPrimaryKey", etc.)
>>
>> > But, the methods always are generated as "insert", "updateByPrimaryKey",
>> > etc.
>>
>> > Besides that, generator works fine, no exceptions, no errors. Any help would
>> > be appreciated.
>>
>> > Thanks
>>
>> > <?xml version="1.0" encoding="UTF-8" ?>
>> > <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis
>> > Generator Configuration 1.0//EN"
>> > "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
>> > <generatorConfiguration >
>> >     <properties resource="database.properties"/>
>> >     <classPathEntry location="/PF/jlibs/hsqldb-2.0.0/lib/hsqldb.jar"/>
>> >     <context
>> >         id="default"
>> >         targetRuntime="MyBatis3">
>> >         <jdbcConnection
>> >             driverClass="${driver}"
>> >             connectionURL="${url}"
>> >             userId="${username}"
>> >             password="${password}" />
>> >         <javaModelGenerator
>> >             targetPackage="juarezmax.demo.mybatis.domain"
>> >             targetProject="demo.mybatis/src/main/java">
>> >         </javaModelGenerator>
>> >         <sqlMapGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java" />
>> >         <javaClientGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java"
>> >             type="ANNOTATEDMAPPER">
>> >             <property name="methodNameCalculator" value="extended" />
>> >         </javaClientGenerator>
>> >         <table
>> >             tableName="vehiculos"
>> >             domainObjectName="Vehiculo">
>> >             <generatedKey
>> >                 column="id"
>> >                 sqlStatement="HSQLDB"
>> >                 identity="true"/>
>> >         </table>
>> >     </context>
>> > </generatorConfiguration>

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

--
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 "methodNameCalculator" property seems to be ignored.

myvideoex
I can control the order of methods and add additional methods and corresponding xml. Adding additional xml can be done by overriding PluginAdapter.sqlMapDocumentGenerated() method rather than sqlMapGenerated().
Thanks again for your guidance.

On Wednesday, April 26, 2017 at 5:58:24 AM UTC+8, Jeff Butler wrote:
In your plugin you can override the sqlMapGenerated() and clientGenerated() methods to add more mapper methods and the corresponding XML.

If you want to change the order of methods in the generated code, then in the configuration, you can specify your own custom type for the JavaClientGenerator.  Then you can have total control over how the methods get generated.

Jeff Butler




On Tue, Apr 25, 2017 at 10:27 AM <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="tGJMu5G7AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">myvi...@...> wrote:
Thank you for your advice. I write a simple plugin with your advice, now I can change method names, and I can also disable some methods. 
I did some investigation, and find that the displaying sequence was controlled in SimpleJavaClientGenerator.getCompilationUnits,maybe I can change sequence or add other method in this method.
I wonder whether I can control the displaying sequence of those methods and whether I can add my custom method&sqlmap to mapper class&xml file within customized plugin or by extending generator? 


On Monday, April 24, 2017 at 10:54:45 PM UTC+8, Jeff Butler wrote:
I'm not aware of any plugin already existing for this so you would need to write a new one. In your plugin, override the initialized(IntrospectedTable) method and then call methods like IntrospectedTable.setInsertStatementId" and IntrospectedTable.setDeleteByPrimaryKeyStatementId.

Jeff Butler


On Mon, Apr 24, 2017 at 9:50 AM <[hidden email]> wrote:
Hi Jeff, I want to customize the generated method named, but I didn't find any plugin to do this task, have I missed something or should I write a new plugin for this task?


On Thursday, February 24, 2011 at 11:07:06 PM UTC+8, Jeff Butler wrote:
Because there are no longer DAO's with MyBatis3 - the Java mapper
names must match the IDs in the XML.  With iBATIS2 the DAO method
names did not need to match the IDs in XML.

If you feel you must change the names, you can do it with a plugin.

Jeff Butler

On Wed, Feb 23, 2011 at 10:19 PM, Paulo Soares <[hidden email]> wrote:


> Why?
>
>
> On 27 jan, 00:32, Jeff Butler <[hidden email]> wrote:
>> That property is ignored when MyBatis3 is the target.  I'll add that
>> to the documentation.
>>
>> Jeff Butler
>>
>> 2011/1/26 Maximiliano Juárez Ramos <[hidden email]>:
>>
>>
>>
>>
>>
>>
>>
>> > Hi,
>>
>> > I'm using MyBatis Generator for Eclipse 1.3.1 and according to the User's
>> > Guide, the <javaClientGenerator> has a property "methodNameCalculator" that
>> > when its value is:
>>
>> > "extended" ---- The generated method names will include the name of the
>> > domain object associated with the method ("insertWidget",
>> > "updateWidgetByPrimaryKey", etc.)
>>
>> > But, the methods always are generated as "insert", "updateByPrimaryKey",
>> > etc.
>>
>> > Besides that, generator works fine, no exceptions, no errors. Any help would
>> > be appreciated.
>>
>> > Thanks
>>
>> > <?xml version="1.0" encoding="UTF-8" ?>
>> > <!DOCTYPE generatorConfiguration PUBLIC "-//<a href="http://mybatis.org//DTD" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2F%2FDTD\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHjp-E8UL0TmmS7A0V54yMfbtfEkA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2F%2FDTD\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHjp-E8UL0TmmS7A0V54yMfbtfEkA&#39;;return true;">mybatis.org//DTD MyBatis
>> > Generator Configuration 1.0//EN"
>> > "<a href="http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2Fdtd%2Fmybatis-generator-config_1_0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGbQhQcAyMHnIvI65x3b69_l8vDOQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmybatis.org%2Fdtd%2Fmybatis-generator-config_1_0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGbQhQcAyMHnIvI65x3b69_l8vDOQ&#39;;return true;">http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
>> > <generatorConfiguration >
>> >     <properties resource="database.properties"/>
>> >     <classPathEntry location="/PF/jlibs/hsqldb-2.0.0/lib/hsqldb.jar"/>
>> >     <context
>> >         id="default"
>> >         targetRuntime="MyBatis3">
>> >         <jdbcConnection
>> >             driverClass="${driver}"
>> >             connectionURL="${url}"
>> >             userId="${username}"
>> >             password="${password}" />
>> >         <javaModelGenerator
>> >             targetPackage="juarezmax.demo.mybatis.domain"
>> >             targetProject="demo.mybatis/src/main/java">
>> >         </javaModelGenerator>
>> >         <sqlMapGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java" />
>> >         <javaClientGenerator
>> >             targetPackage="juarezmax.demo.mybatis.mappers"
>> >             targetProject="demo.mybatis/src/main/java"
>> >             type="ANNOTATEDMAPPER">
>> >             <property name="methodNameCalculator" value="extended" />
>> >         </javaClientGenerator>
>> >         <table
>> >             tableName="vehiculos"
>> >             domainObjectName="Vehiculo">
>> >             <generatedKey
>> >                 column="id"
>> >                 sqlStatement="HSQLDB"
>> >                 identity="true"/>
>> >         </table>
>> >     </context>
>> > </generatorConfiguration>

--
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 mybatis-user...@googlegroups.com.

For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="tGJMu5G7AwAJ" 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.
Loading...