Skip to content

Add SQL provider class that help detecting a template file automatically #10

@kazuki43zoo

Description

@kazuki43zoo

for example:

package com.example.demo.mapper;

interface DemoMapper {
  @InsertProvider(type = TemplateFilePathProvider.class)
  void insert(Demo demo);
}

By default, you can load a template file (e.g. com/example/demo/mapper/DemoMapper/DemoMapper-insert.sql) automatically.

project-root
  + src
    + main
       + resources (just under class-path )
          + com
             + example
                + demo
                   + mapper
                      + DemoMapper 
                         - DemoMapper-insert.sql

This feature depends on mybatis/mybatis-3#1391 and mybatis/mybatis-3#1503. In other words, this feature required to use on MyBatis 3.5.1+.

Also you can customize path format using static setter methods of TemplateFilePathProvider.

  • Can excludes mapper name in template file (e.g. com/example/demo/mapper/DemoMapper/insert.sql)
project-root
  + src
    + main
       + resources (just under class-path )
          + com
             + example
                + demo
                   + mapper
                      + DemoMapper 
                         - insert.sql
  • Can exclude directory per mapper (e.g. com/example/demo/mapper/DemoMapper-insert.sql)
project-root
  + src
    + main
       + resources (just under class-path )
          + com
             + example
                + demo
                   + mapper
                      - DemoMapper-insert.sql
  • Can excludes a package path (e.g. DemoMapper/DemoMapper-insert.sql)
project-root
  + src
    + main
       + resources (just under class-path )
           + DemoMapper 
               - DemoMapper-insert.sql
  • Can adding a path prefix (e.g. sqls/)
project-root
  + src
    + main
       + resources (just under class-path )
          + sqls
             + com
                + example
                   + demo
                      + mapper
                         + DemoMapper 
                             - DemoMapper-insert.sql

Document

Related links

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy