Generate code

You should never ever try to create mapper XML or CRDU elements yourself manually which is slow and error-prone. The plugin provides useful intention action to help you create them conveniently. There are three main user cases which we'll illustrate one by one.

No mapper XML present

You can create both mapper XML file and XML element at the same time when the corresponding mapper XML of a mapper interface is absent (and of course, no annotation statement is present as well). You can use Create new XML statement intention action which allows you to specify how the mapper elements should be generated to generate the XML statement automatically.

mapper-xml-absent.gif

No SQL implementation present

A method in an interface will be highlighted as an error if it meets the following two requirements:

  • The plugin determines that the interface is a mapper interface
  • No corresponding SQL implementation is present in either annotation or mapper XML

If a mapper interface has a single corresponding mapper XML file, the Destination file field will be filled with the path of that mapper XML file. If a mapper interface has many corresponding mapper XML files, then you can choose one where the newly generated element should be placed.

no-sql-implementation.gif

Create mapper method from mapper XML

On the other side, we can create mapper method from mapper XML if corresponding mapper method is absent:

mapper-method-absent.gif

Alias

parameterType and resultType will be filled with alias automatically if the plugin determines that corresponding alias is available, otherwise qualified class name will be used if alias is not available.

@Param

In case you need it, the plugin provides an intention action to apply the @Param annotation to parameters of a mapper method, the name of a parameter will be used as the value of @Param:

param.gif

Codes Magic © 2013-2018 · Terms