mybatis / mybatipse

Eclipse plugin adding support for MyBatis SQL Mapper Framework.
Eclipse Public License 1.0
333 stars 92 forks source link

Copy debug log as an executable SQL statement #54

Closed harawata closed 8 years ago

harawata commented 8 years ago

MyBatis outputs executed statements and paramters in the debug log.

DEBUG [main] - ==>  Preparing: insert into users values(?, ?) 
DEBUG [main] - ==> Parameters: 2(Integer), User2(String)
DEBUG [main] - <==    Updates: 1

Sometimes, I want to copy a statement to execute in another query tool, for example. But replacing the parameters manually is tedious.

So, a new menu item will be added to the contextual menu of the Console View.

  1. In the Console View, select the dubug output of the statement. The selection must include the first ==> and the <== after the parameters line.
  2. Right-click the selection and choose 'Copy MyBatis Statement' from the contexctual menu.
  3. The placeholders '?' are replaced with the parameter values and the resulting statement is copied to your clipboard.
insert into users values(2, 'User2')
harawata commented 8 years ago

Thanks for voting! I am happy to know that I am not the only one who finds this feature useful 😆

I am thinking about creating a single-feature .jar application for non-Eclipse users.

  1. Copy the string from a log file or other IDE's console view.
  2. Launch the .jar application.
  3. An executable SQL statement is copied to the clipboard.

It is not elegant, but could save some time, for sure. Let me know if anyone interested!