Git Product home page Git Product logo

mybatipse's Introduction

MyBatipse : Eclipse plugin for MyBatis

MyBatis is a popular SQL Mapper framework.
And MyBatipse is an Eclipse plug-in which provids content assists and validations when editing MyBatis related files.

Features

XML Editor Enhancements

Auto-completion

  • Mapper namespace : Calculated from the path.
    autocomplete namespaceautocomplete namespace

  • Java class/Type alias : Propose Java classes and Type Aliases (translucent icons). Camelcase match is supported. [1] [2]
    autocomplete class autocomplete class

  • Java property : Propose properties of the parent java class. Nested properties are supported.
    autocomplete property autocomplete property

  • Statement ID : If corresponding mapper interface exists, propose the method name as a statement ID.
    autocomplete statement id

  • Reference to resultMap/select/sql : Propose ID of the referenced resultMap/select/sql. External reference is supported (blue icons).
    autocomplete reference

  • Parameter properties : #{} and ${} in select/insert/udpate/delte statements. Also works in some attributes.
    autocomplete properties autocomplete properties 2

  • javaType, jdbcType, typeHandler in #{}
    autocomplete jdbcType

  • Result elements in resultMap/collection/association : Generates elements for the parent java class properties.
    autocomplete results

  • setting name and value in XML config.
    autocomplete setting autocomplete setting

  • [1] For better performance, classes in the application libraries (loaded as JARs) are listed only when at least one package segment is specified.

  • [2] There is a limitation for the type alias support. Basically, if type aliases are registered using Java API, they are not automatically detected. As a workaround, you can register type aliases in MyBatipse's preference. See the Configuration section.

Hyperlinks

  • To referenced resultMap/select/sql element. External reference is supported.
    link to external reference
  • From Java mapper interface to XML mapper element.
    link to xml mapper
  • From Java mapper method to XML mapper element.
    link to xml statement
  • From XML statement id to Java mapper method.
    link to java method

Validation

  • Missing TypeAlias, Java class/property.
  • Missing resultMap/select/sql ID.
  • etc.
    refid error problem view

Mapper Declaration View

Java Editor Enhancements

Auto-completion

  • Parameter properties : #{} and ${} in select/insert/udpate/delte annotations. autocomplete properties in java
  • Return type properties in @Result
    autocomplete return type properties in java
  • keyProperty in @Options and @SelectKey
    autocomplete return type properties in java
    autocomplete return type properties in java
  • javaType, jdbcType, typeHandler in #{} : See the XML example.
  • Reference to resultMap in @ResultMap and resultMap attribute of @Arg
    autocomplete resultmap annotation
  • select attribute of @Arg, @Many and @One
    autocomplete select

Quick Assist

Put the cursor on the statement method name and press cmd + 1 (or ctrl + 1) to trigger Quick Assist.

  • You can add @Param to method parameters.
    param-annotation1
    param-annotation2
  • You can copy annotation statement into the clipboard. param-annotation1
  • You can move annotation statement to XML mapper.
    move-statement

Validation

  • @ResultMap : invalid resultMap ID.
  • select attribute of @One or @Many : invalid statement ID.

Rename Refactoring

  • Renaming resultMap/statement/sql ID updates its references in Java and XML mappers.
  • In XML mapper, right click -> Refactor -> Rename MyBatis element. param-annotation1
  • In Java mapper, right click -> MyBatis Refactor -> Rename MyBatis element. param-annotation1
  • Renaming a Java mapper method also updates its references.

Miscellaneous

  • Wizard to create a new XML mapper file.
    wizard-xml-mapper

  • Smart-copy menu in Console View to copy SQL statement in an executable form. For example, if you select and copy the following debug output ...
    smart-copy-console
    ... and the following statement is copied to the clipboard.

insert into users values(2, 'User2')


## Configuration

### XML mapper location
- MyBatipse searches XML mapper files under your project's __Source Folder__. To make a directory __Source Folder__, right click the directory in the package explorer and choose __Build Path__ -> __Use as Source Folder__ from the menu.

### MyBatis Nature
- By default, each file is validated when it's saved, but you would want to validate the XML mapper when the related Java classes are updated as well. For that purpose, MyBatipse provides a custom nature __MyBatis Nature__.  
To add the nature, right click the project in the package explorer and choose __Configure__ -> __Add MyBatis Nature__ from the menu.   
![nature](screen/nature.png)

### Type Alias
- Type alias are automatically detected _if_ they are registered using XML config file (both mybatis and mybatis-spring config is supported).  
If you register type aliases in Java code, MyBatipse cannot detect them. As a workaround, you can register custom type aliases in the project setting (Open __Project__ -> __Properties__ menu and select __MyBatipse__ from the left column).  
![type aliases](screen/pref-alias.png)   
For example, with the above settings: 
  - The first entry registers all the classes in ```com.example.domain``` package as type aliases.  
  - The second entry registers the single class ```domain.Person```.  
  - The third entry registers the single class ```domain.SomeLongNamedBean``` under the alias ```SomeBean```.
  - Note that, in any case, MyBatipse respects ```@Alias``` annotation if it exists.

### Java 8 `-parameters` compiler option support

- If 'Store information about method parameters' option is enabled in the Java Compiler -> Classfile Generation setting, MyBatipse proposes the declared method parameter names.  
![xml proposal order](screen/actual-parameters.png)  


## Tips
- To move MyBatis proposals to the top of the XML proposal list, quit Eclipse and open the following file in the workspace: ```.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.ui.prefs``` Find the line started with ```xml_content_assist_default_page_sort_order=``` and insert ```net.harawata.mybatis.proposalCategory.xml\u0000``` right after the equal sign.  
![xml proposal order](screen/xml-proposal-order.png)  



## Installation

There are several ways to install MyBatipse.

- Drag this button [![drag-to-install button](http://marketplace.eclipse.org/misc/installbutton.png)](http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=1467819)  from browser to your Eclipse workbench (i.e. window).
- Choose __Eclipse Marketplace...__ in __Help__ menu of your Eclipse and search __MyBatipse__.
- Choose __Install New Software...__ in __Help__ menu and enter the following URL.  
http://dl.bintray.com/harawata/eclipse

## Bugs, questions, suggestions, etc.
Please use the [issue tracker](https://github.com/harawata/mybatipse/issues).  


## License
MyBatipse is licensed under [__Eclipse Public License 1.0__](http://www.eclipse.org/legal/epl-v10.html).

mybatipse's People

Contributors

harawata avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.