Skip to content

Cannot scan TypeHandler that pass Class<?> to constructor #394

@kazuki43zoo

Description

@kazuki43zoo

Since 2.0.1, the SqlSessionFactoryBean cannot scan TypeHandler that pass Class<?> to constructor as follow:

@MappedTypes(JSONObject.class)
public class JSONObjectTypeHandler extends BaseTypeHandler<JSONObject> {

    public JSONObjectTypeHandler(Class<JSONObject> type) {
        super(type);
    }
    // ...
}

The cause of this behavior was created by #359. In this changes, it scan only TypeHandler that can create instance using default constructor.
We should be scan TypeHandler that create instance using constructor that pass Class or default constructor.

Related Issues

Workaround

You can specify a custom type handler using typeHandlers property as follow:

  • Java Configuration
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
factoryBean.setTypeHanlders(new JSONObjectTypeHandler(JSONObject.class));
// ...
  • XML Configuration
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  <property name="typeHanlders">
    <array>
      <bean class="com.example.typehandler.JSONObjectTypeHandler">
        <constructor-arg value="com.example.json.JSONObject" />
      </bean>
    </array>
    </bean>
  </property>
  <!-- ... -->
</bean>

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy