Sunday, March 8, 2015

FreeMarker plugin for MyBatis

Kostromin Igor has created a project to provide a FreeMarker plugin for MyBatis.

This is how a mapper looks like with FreeMarker:

@Select("select * from names where id in (${ids?join(',')})")
List<Name> findNamesByIds(@Param("ids") List<Integer> ids);

You can also use FreeMarker templates this way:

Name findName(@Param("n") String name);

Where findName.ft1 is:

FROM names
where firstName = <@p name="n"/>
See more and contribute at the project's page at Github