Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MybatisTraning
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
zero
MybatisTraning
Commits
a68b1a4d
Commit
a68b1a4d
authored
Dec 11, 2019
by
Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
8bb2333e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
ContentTypeHandler.java
.../src/main/java/com/mybatis/handle/ContentTypeHandler.java
+46
-0
No files found.
张志墙_Mybatis1/src/main/java/com/mybatis/handle/ContentTypeHandler.java
0 → 100644
View file @
a68b1a4d
package
com
.
mybatis
.
handle
;
package
com
.
mybatis
.
handle
;
import
com.mybatis.model.Context
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.ibatis.type.BaseTypeHandler
;
import
org.apache.ibatis.type.JdbcType
;
import
org.apache.ibatis.type.MappedJdbcTypes
;
import
org.apache.ibatis.type.MappedTypes
;
import
java.sql.CallableStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
@MappedTypes
(
Context
.
class
)
@MappedJdbcTypes
(
JdbcType
.
VARCHAR
)
public
class
ContentTypeHandler
extends
BaseTypeHandler
<
Context
>
{
@Override
public
void
setNonNullParameter
(
PreparedStatement
preparedStatement
,
int
i
,
Context
context
,
JdbcType
jdbcType
)
throws
SQLException
{
String
str
=
JSONObject
.
toJSONString
(
context
);
preparedStatement
.
setString
(
i
,
str
);
}
@Override
public
Context
getNullableResult
(
ResultSet
resultSet
,
String
s
)
throws
SQLException
{
String
string
=
resultSet
.
getString
(
s
);
return
JSONObject
.
parseObject
(
string
,
Context
.
class
);
}
@Override
public
Context
getNullableResult
(
ResultSet
resultSet
,
int
i
)
throws
SQLException
{
String
string
=
resultSet
.
getString
(
i
);
return
JSONObject
.
parseObject
(
string
,
Context
.
class
);
}
@Override
public
Context
getNullableResult
(
CallableStatement
callableStatement
,
int
i
)
throws
SQLException
{
String
string
=
callableStatement
.
getString
(
i
);
return
JSONObject
.
parseObject
(
string
,
Context
.
class
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment