Giter Site home page Giter Site logo

mybatis-types's Introduction

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.

Note that my handlers forced to return not null value (empty array for null db column).

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.

Also it does not return null for null DB columns, but empty Map or Properties.

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.jneat.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.jneat.mybatis.InstantTypeHandler"/>
  <typeHandler handler="com.github.jneat.mybatis.LocalDateTypeHandler"/>
  <typeHandler handler="com.github.jneat.mybatis.LocalDateTimeTypeHandler"/>
  <typeHandler handler="com.github.jneat.mybatis.LocalTimeTypeHandler"/>
  <typeHandler handler="com.github.jneat.mybatis.OffsetDateTimeTypeHandler"/>
  <typeHandler handler="com.github.jneat.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.jneat.mybatis" />
</bean>

mybatis-types's People

Contributors

rumatoest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mybatis-types's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.