INSERT INTO ferias (audit_dt, audit_usuario, audit_st_ope, feri_cfun_cd_mat, feri" /> INSERT INTO ferias (audit_dt, audit_usuario, audit_st_ope, feri_cfun_cd_mat, feri" /> INSERT INTO ferias (audit_dt, audit_usuario, audit_st_ope, feri_cfun_cd_mat, feri"/>

MyBatis - Insert with TypeHandler - java.lang.ClassNotFoundException

2.5k Views Asked by At

Mapper.xml

<insert id = "insertVacation" parameterType = "Vacation">
    INSERT INTO ferias (audit_dt, audit_usuario, audit_st_ope,
    feri_cfun_cd_mat, feri_fepa_ano, feri_sq, feri_dt_inicio, feri_dt_fim,
    feri_fsfr_cd, feri_st_pag, feri_ds_obs, feri_st_ad13sal, feri_dt_pagref,
    feri_st_autorizado, fepa_st_recebe_adferias, feri_fl_periodo_ativo,
    feri_dt_programacao, feri_dt_autorizacao, feri_tp_programacao,
    feri_fl_adiantamento_durante, feri_fl_13_durante ) 
    VALUES (#{auditDate, typeHandler="br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"}, #{auditUser}, #{auditStatus}, #{userCode},
    #{currentYear}, #{sequencial}, #{initialPeriod}, #{finalPeriod},
    #{status}, #{paymentStatus}, #{note}, #{advance13th}, #{paymentDate}, 
    #{statusAuthorized}, #{additional}, #{activePeriod}, #{scheduleDate}, 
    #{authorizationDate}, #{typeProgramming}, #{advanceVacation}, 
    #{advance13thVacation} )    
</insert>

mybatis-config.xml

<typeHandlers>
    <typeHandler javaType="org.joda.time.DateTime" jdbcType="DATE" handler="br.gov.df.terracap.grh.util.DateTimeTypeHandler"/>
    <typeHandler javaType="org.joda.time.LocalDateTime" jdbcType="TIMESTAMP" handler="br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"/>
</typeHandlers>

Error when test the Insert

### Error updating database. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias '"br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"'. Cause: java.lang.ClassNotFoundException: Cannot find class: "br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler" ### Cause: org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias '"br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"'. Cause: java.lang.ClassNotFoundException: Cannot find class: "br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler" org.apache.ibatis.exceptions.PersistenceException

1

There are 1 best solutions below

0
Thialles Braga On

VALUES (#{auditDate, typeHandler="br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"}

Correct:

VALUES (#{auditDate, typeHandler=br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler}

*without quotes