Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7183123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:54:58+00:00 2026-05-28T17:54:58+00:00

I am using MyBatis with Spring Integration as described here . I am further

  • 0

I am using MyBatis with Spring Integration as described here.

I am further using the Joda Date API instead of the Java Date API, now the tricky bit is ensure that MyBatis recognizes the Joda Date API, and enables me to query the same.

Now the documented way to achieve this is to use a DateTypeHandler

I am assuming that if we use the correct annotations, Mybatis will pick up the custom handler and register it with the sqlsessionfactory.

So my class looks like

@MappedTypes(value = DateTime.class)
@MappedJdbcTypes(value = {JdbcType.DATE,JdbcType.TIME,JdbcType.TIMESTAMP})

public class MyBatisJodaDateTimeType extends DateTypeHandler {
......
.....
}

Some how this does not register my Custom Type handler …., What I am having to do, is write code like this at application startup …

 SqlSessionFactory mybatisSessionFactory = applicationContext.getBean("sqlSessionFactory", SqlSessionFactory.class);
        MyBatisJodaDateTimeType myBatisJodaDateTimeType = applicationContext.getBean("myBatisJodaDateTimeType", MyBatisJodaDateTimeType.class);

        mybatisSessionFactory.getConfiguration().getTypeHandlerRegistry().register(DateTime.class, myBatisJodaDateTimeType);
        mybatisSessionFactory.getConfiguration().getTypeHandlerRegistry().register(DateTime.class, JdbcType.DATE, myBatisJodaDateTimeType);
        mybatisSessionFactory.getConfiguration().getTypeHandlerRegistry().register(DateTime.class, JdbcType.TIME, myBatisJodaDateTimeType);
        mybatisSessionFactory.getConfiguration().getTypeHandlerRegistry().register(DateTime.class, JdbcType.TIMESTAMP, myBatisJodaDateTimeType);
        mybatisSessionFactory.getConfiguration().getTypeHandlerRegistry().register(DateTime.class, null, myBatisJodaDateTimeType);

I know it looks like crap and i want to avoid it, cant i get MyBatis to scan my application for these annotations and then register my custom type handler automatically ?

I am sure that my type has not been registered (Using just the annotations) because i did a inspect in the MYBatis code and could not find my handler there ….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:54:59+00:00Added an answer on May 28, 2026 at 5:54 pm

    I ran into the same problem, also for a Joda DateTime TypeHandler. Tracing through, I see that the handler is actually registered. However, TypeHandlerRegistry.getTypeHandler seems to use a null jdbcType to look up the handler.

    Now, the last line in your code snippet above explicitly registers a handler for null JdbcType. Unfortunately, it seems to be impossible to include null in the @MappedJdbcTypes annotation. So that looks like a bug to me.

    Oh, and you may be able to just remove the @MappedJdbcTypes annotation altogether, to get it working.

    UPDATE:

    Here’s how I set up in my applicationContext.xml:

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="mapperLocations" value="classpath*:META-INF/persistence/*.xml" />
        <property name="typeAliasesPackage" value="com.mycompany.data" />
        <property name="typeHandlersPackage" value="com.mycompany.typehandler" />
    </bean>
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.mycompany.persistence" />
    </bean>
    

    If you pick up type handlers by scanning a package like this, you can set the MyBatis logging level to debug to see which ones it attempts to add.

    My TypeHandler starts like this:

    @MappedTypes(DateTime.class)
    public class DateTimeTypeHandler implements TypeHandler<DateTime> {...}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on Apache Tomcat 6.0.29.
I want to build an application using Hibernate and MyBatis integrate with Spring. In
I develop java application using Spring 3.0.5 and I work with database Oracle using
I'm currently working with MyBatis-Spring integration framework and that's what I read from docs:
I have been trying to create a Spring project that uses MyBatis for the
I have a web application set up with MyBatis and Spring, but it doesn't
I need to get the list of columns in a table using mybatis/ibatis in
(Using MyBatis v3.0.4.) I have a problem that I do not know how to
I am using MyBatis 3.0.3 and have problem: some columns in database have names
Let's say I have swing app and I am using mybatis: public class MyAppCView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.