Skip to content

Type Handlers for Mybatis 3.x including Java 8 time (JSR 310) support

License

Notifications You must be signed in to change notification settings

amilarajans/mybatis-types

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Additional MyBatis type handlers for Java 8 runtime without extra dependencies

Release
API javadoc

Project features

Java 8 time (JSR 310) support for Mybatis

This packages provide mybatis type handlers for core java.time.* types:

  • java.time.Instant (via java.sql.Timestamp)
  • java.time.LocalDate (via java.sql.Date)
  • java.time.LocalDateTime (via java.sql.Timestamp)
  • java.time.LocalTime (via java.sql.Time)
  • java.time.OffsetDateTime (via java.sql.Timestamp)
  • java.time.ZonedDateTime (via java.sql.Timestamp)

Arrays support

Generally JDBC driver has built-in support for array types. Thus any DB with array support can be supported.

I'm provide support only for PostgreSQL array types. Theoretically adding new DB will require only several lines of code, but I do not have time for this. Fell free to contribute if you require new DB support for arrays.

Java properties and key-value map support

Underlying concept is simple - any text field can have content in format of properties file.

This package provide a way to read/write properties into text fields. In your application you can use Map<String,String> or java.util.Properties objects to store/read your fields.

Add to your project

You can add this artifact to your project using JitPack.
All versions list, instructions for gradle, maven, ivy etc. can be found by link above.

To get latest commit use -SNAPSHOT instead version number.

Configure

Mybatis config

<!-- mybatis-config.xml -->
<typeHandlers>
  <package name="com.github.javaplugs.mybatis"/>
</typeHandlers>

Or you can specify each type handler class one by one. In a case if you are need particular handlers only.

<!-- mybatis-config.xml -->
<typeHandlers>
  <typeHandler handler="com.github.javaplugs.mybatis.InstantTypeHandler"/>
  <typeHandler handler="com.github.javaplugs.mybatis.LocalDateTypeHandler"/>
  <typeHandler handler="com.github.javaplugs.mybatis.LocalDateTimeTypeHandler"/>
  <typeHandler handler="com.github.javaplugs.mybatis.LocalTimeTypeHandler"/>
  <typeHandler handler="com.github.javaplugs.mybatis.OffsetDateTimeTypeHandler"/>
  <typeHandler handler="com.github.javaplugs.mybatis.ZonedDateTimeTypeHandler"/>
  <!-- and other handlers -->
</typeHandlers>

Mybatis via Spring

<bean id="SomeId" class="org.mybatis.spring.SqlSessionFactoryBean">
    <!-- your configuration -->
    <property name="typeHandlersPackage" value="com.github.javaplugs.mybatis" />
</bean>

About

Type Handlers for Mybatis 3.x including Java 8 time (JSR 310) support

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%