T
- the type of the variable being persistedpublic class JacksonJsonBasedTypeHandler<T> extends Object implements org.apache.ibatis.type.TypeHandler<T>
TypeHandler
that uses ObjectMapper
to map the values into a String.Modifier and Type | Field and Description |
---|---|
protected com.fasterxml.jackson.core.type.TypeReference<T> |
jacksonTypeReference |
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
Constructor and Description |
---|
JacksonJsonBasedTypeHandler(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
com.fasterxml.jackson.core.type.TypeReference<T> jacksonTypeReference) |
Modifier and Type | Method and Description |
---|---|
T |
getResult(CallableStatement cs,
int columnIndex) |
T |
getResult(ResultSet rs,
int columnIndex) |
T |
getResult(ResultSet rs,
String columnName) |
protected String |
getValueAsString(T parameter) |
protected T |
readValue(Reader reader) |
void |
setParameter(PreparedStatement ps,
int i,
T parameter,
org.apache.ibatis.type.JdbcType jdbcType) |
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected final com.fasterxml.jackson.core.type.TypeReference<T> jacksonTypeReference
public JacksonJsonBasedTypeHandler(com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.fasterxml.jackson.core.type.TypeReference<T> jacksonTypeReference)
public void setParameter(PreparedStatement ps, int i, T parameter, org.apache.ibatis.type.JdbcType jdbcType) throws SQLException
setParameter
in interface org.apache.ibatis.type.TypeHandler<T>
SQLException
public T getResult(ResultSet rs, String columnName) throws SQLException
getResult
in interface org.apache.ibatis.type.TypeHandler<T>
SQLException
public T getResult(ResultSet rs, int columnIndex) throws SQLException
getResult
in interface org.apache.ibatis.type.TypeHandler<T>
SQLException
public T getResult(CallableStatement cs, int columnIndex) throws SQLException
getResult
in interface org.apache.ibatis.type.TypeHandler<T>
SQLException
protected String getValueAsString(T parameter) throws com.fasterxml.jackson.core.JsonProcessingException
com.fasterxml.jackson.core.JsonProcessingException
protected T readValue(Reader reader) throws IOException
IOException
Copyright © 2019. All rights reserved.