Hint
This article is generated by AI translation.
JSON Serialization Handler
JSON serialization handlers are located in the net.hasor.dbvisitor.types.handler.json package. Through serialization handlers, you can store Java objects as JSON in text columns of the database.
Use in object mapping
public class User {
@Column(typeHandler = JsonTypeHandler.class)
private UserExtInfo moreInfo;
// getters and setters omitted
}
Use in SQL statements
update users
set more_info = #{arg1, typeHandler=net.hasor.dbvisitor.types.handler.json.JsonTypeHandler}
where id = #{arg0}
info
Before using JSON serialization handlers, you need to add the corresponding JSON library dependency to your project.
Built-in Implementations
JSON Serialization
| Handler | Description |
|---|---|
JsonTypeHandler | Auto-detects, tries Jackson → Gson → Fastjson → Fastjson2 in order to find an available JSON library |
JsonUseForJacksonTypeHandler | Uses Jackson |
JsonUseForGsonTypeHandler | Uses Gson |
JsonUseForFastjsonTypeHandler | Uses Fastjson |
JsonUseForFastjson2TypeHandler | Uses Fastjson2 |
BSON Serialization
| Handler | Description |
|---|---|
BsonTypeHandler | Uses MongoDB BSON library for serialization/deserialization |
BsonListTypeHandler | BSON-based handling for List, Set and other collection fields, with automatic generic type detection |