April 2018
Intermediate to advanced
202 pages
4h 48m
English
MyBatis uses mapper classes (actually, interfaces) to define the methods that will map SQL queries to Java objects. These are almost the equivalent of the repository classes we have developed so far. However, it makes sense to use MyBatis terminology when using it. Also, as we'll see later, we need to add transaction or session management code around the calls to the mapper class, but let's start with the mapper class. If you were observant, the mybatis-config.xml file defined a mapper class in the mappers section. Go back and have a look at it. The following is the definition of such a mapper:
public interface MessageMapper { @Select("SELECT id, content FROM messages") List<Message> findAll(); @Insert("INSERT ...
Read now
Unlock full access