mybatis / mybatipse

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

"Copy MyBatis Statement" does not work with @Many subselects #81

Closed mathisdt closed 6 years ago

mathisdt commented 6 years ago

The entry "Copy MyBatis Statement" from the context menu in the Eclipse console does not work with @Many subselects.

Example mapper:

@Select({
  "select ..."
})
@Results({
  @Result(column = "ID", property = "id", id = true),
  ...
  @Result(column = "SOMETHING_ELSE", property = "somethingElse", javaType = List.class,
    many = @Many(select = "selectSomethingElse")),
})
List<Something> select(@Param("from") LocalDate from, @Param("to") LocalDate to);

@Select({
  "select ...",
  "where abc.something_else_id=#{somethingElseId}"
})
@Results({
  ...
})
List<SomethingElse> selectSomethingElse(@Param("somethingElseId") Long somethingElseId);

Example output:

...Mapper.select ==>  Preparing: select ... 
...Mapper.select ==> Parameters: 2018-05-14(Date), 2018-06-12(Date)
...Mapper.selectSomethingElse ====>  Preparing: select ... 
...Mapper.selectSomethingElse ====> Parameters: 8(Long)
...Mapper.selectSomethingElse <====      Total: 23
...Mapper.selectSomethingElse ====>  Preparing: select ... 
...Mapper.selectSomethingElse ====> Parameters: 9(Long)
...Mapper.selectSomethingElse <====      Total: 19
...Mapper.select <==      Total: 2

When I select all of the above output and use the context menu item "Copy MyBatis Statement", I only get the raw prepared statement containing the ? placeholders, the values are not inserted into it.

harawata commented 6 years ago

Thank you for the report, @mathisdt . This should be fixed in 1.1.1.

The selection must include the following portion of the log at least.

==>  Preparing: select ... 
...Mapper.select ==> Parameters: 2018-05-14(Date), 2018-06-12(Date)
...Mapper.selectSomethingElse ====>  Preparing: