O'Reilly logo

Java Persistence with MyBatis 3 by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

MyBatis recipes

In addition to simplifying the database programming, MyBatis provides various features that are very useful for implementing some common tasks, such as loading the table rows page by page, storing and retrieving CLOB/BLOB type data, and handling enumerated type values, among others. Let us have a look at a few of these features.

Handling enumeration types

MyBatis supports persisting enum type properties out of the box. Assume that the STUDENTS table has a column gender of the type varchar to store either MALE or FEMALE as the value. And, the Student object has a gender property that is of the type enum as shown in the following code:

public enum Gender 
{
  FEMALE,
  MALE
}

By default, MyBatis uses EnumTypeHandler to handle enum type ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required