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_97
MybatisTraning
Commits
2ab62d7e
Commit
2ab62d7e
authored
Dec 10, 2019
by
chuwanshun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
阮艺博作业提交
parent
c5508540
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
432 additions
and
0 deletions
+432
-0
.classpath
阮艺博_MyBatis1/阮艺博_MyBatis1/.classpath
+36
-0
.name
阮艺博_MyBatis1/阮艺博_MyBatis1/.idea/.name
+3
-0
Project_Default.xml
...阮艺博_MyBatis1/.idea/inspectionProfiles/Project_Default.xml
+38
-0
misc.xml
阮艺博_MyBatis1/阮艺博_MyBatis1/.idea/misc.xml
+15
-0
workspace.xml
阮艺博_MyBatis1/阮艺博_MyBatis1/.idea/workspace.xml
+0
-0
.project
阮艺博_MyBatis1/阮艺博_MyBatis1/.project
+38
-0
.jsdtscope
阮艺博_MyBatis1/阮艺博_MyBatis1/.settings/.jsdtscope
+14
-0
org.eclipse.jdt.core.prefs
...yBatis1/阮艺博_MyBatis1/.settings/org.eclipse.jdt.core.prefs
+10
-0
org.eclipse.m2e.core.prefs
...yBatis1/阮艺博_MyBatis1/.settings/org.eclipse.m2e.core.prefs
+5
-0
org.eclipse.wst.common.component
...1/阮艺博_MyBatis1/.settings/org.eclipse.wst.common.component
+12
-0
org.eclipse.wst.common.project.facet.core.xml
...1/.settings/org.eclipse.wst.common.project.facet.core.xml
+8
-0
org.eclipse.wst.jsdt.ui.superType.container
...is1/.settings/org.eclipse.wst.jsdt.ui.superType.container
+3
-0
org.eclipse.wst.jsdt.ui.superType.name
...MyBatis1/.settings/org.eclipse.wst.jsdt.ui.superType.name
+3
-0
org.eclipse.wst.validation.prefs
...1/阮艺博_MyBatis1/.settings/org.eclipse.wst.validation.prefs
+3
-0
pom.xml
阮艺博_MyBatis1/阮艺博_MyBatis1/pom.xml
+41
-0
Test0Entity.java
...Batis1/阮艺博_MyBatis1/src/main/java/entity/Test0Entity.java
+32
-0
TypeJsonHandler.java
...1/阮艺博_MyBatis1/src/main/java/handler/TypeJsonHandler.java
+51
-0
Test0Mapper.java
...Batis1/阮艺博_MyBatis1/src/main/java/mapper/Test0Mapper.java
+20
-0
MyBatisTest0.java
...yBatis1/阮艺博_MyBatis1/src/main/java/test/MyBatisTest0.java
+58
-0
db.properties
阮艺博_MyBatis1/阮艺博_MyBatis1/src/main/resources/db.properties
+5
-0
mybatis-config.xml
...Batis1/阮艺博_MyBatis1/src/main/resources/mybatis-config.xml
+29
-0
web.xml
阮艺博_MyBatis1/阮艺博_MyBatis1/src/main/webapp/WEB-INF/web.xml
+8
-0
No files found.
阮艺博_MyBatis1/阮艺博_MyBatis1/.classpath
0 → 100644
View file @
2ab62d7e
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"src"
output=
"target/classes"
path=
"src/main/java"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
excluding=
"**"
kind=
"src"
output=
"target/classes"
path=
"src/main/resources"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
output=
"target/test-classes"
path=
"src/test/java"
>
<attributes>
<attribute
name=
"test"
value=
"true"
/>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"org.eclipse.jst.component.dependency"
value=
"/WEB-INF/lib"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.5"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.junit.JUNIT_CONTAINER/5"
/>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
</classpath>
阮艺博_MyBatis1/阮艺博_MyBatis1/.idea/.name
0 → 100644
View file @
2ab62d7e
MyBatisTest
MyBatisTest
\ No newline at end of file
阮艺博_MyBatis1/阮艺博_MyBatis1/.idea/inspectionProfiles/Project_Default.xml
0 → 100644
View file @
2ab62d7e
<component
name=
"InspectionProjectProfileManager"
>
<component
name=
"InspectionProjectProfileManager"
>
<profile
version=
"1.0"
>
<option
name=
"myName"
value=
"Project Default"
/>
<inspection_tool
class=
"JavaDoc"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<option
name=
"TOP_LEVEL_CLASS_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
""
/>
</value>
</option>
<option
name=
"INNER_CLASS_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
""
/>
</value>
</option>
<option
name=
"METHOD_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
"@return@param@throws or @exception"
/>
</value>
</option>
<option
name=
"FIELD_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
""
/>
</value>
</option>
<option
name=
"IGNORE_DEPRECATED"
value=
"false"
/>
<option
name=
"IGNORE_JAVADOC_PERIOD"
value=
"true"
/>
<option
name=
"IGNORE_DUPLICATED_THROWS"
value=
"false"
/>
<option
name=
"IGNORE_POINT_TO_ITSELF"
value=
"false"
/>
<option
name=
"myAdditionalJavadocTags"
value=
"date"
/>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
阮艺博_MyBatis1/阮艺博_MyBatis1/.idea/misc.xml
0 → 100644
View file @
2ab62d7e
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"MavenProjectsManager"
>
<option
name=
"originalFiles"
>
<list>
<option
value=
"$PROJECT_DIR$/pom.xml"
/>
</list>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/out"
/>
</component>
</project>
\ No newline at end of file
阮艺博_MyBatis1/阮艺博_MyBatis1/.idea/workspace.xml
0 → 100644
View file @
2ab62d7e
This diff is collapsed.
Click to expand it.
阮艺博_MyBatis1/阮艺博_MyBatis1/.project
0 → 100644
View file @
2ab62d7e
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
MyBatisTest
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.wst.common.project.facet.core.builder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.m2e.core.maven2Builder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.wst.validation.validationbuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jem.workbench.JavaEMFNature
</nature>
<nature>
org.eclipse.wst.common.modulecore.ModuleCoreNature
</nature>
<nature>
org.eclipse.jdt.core.javanature
</nature>
<nature>
org.eclipse.m2e.core.maven2Nature
</nature>
<nature>
org.eclipse.wst.common.project.facet.core.nature
</nature>
<nature>
org.eclipse.wst.jsdt.core.jsNature
</nature>
</natures>
</projectDescription>
阮艺博_MyBatis1/阮艺博_MyBatis1/.settings/.jsdtscope
0 → 100644
View file @
2ab62d7e
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
excluding=
"**/bower_components/*|**/node_modules/*|**/*.min.js"
kind=
"src"
path=
"src/main/webapp"
/>
<classpathentry
kind=
"src"
path=
"target/m2e-wtp/web-resources"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.wst.jsdt.launching.JRE_CONTAINER"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.wst.jsdt.launching.WebProject"
>
<attributes>
<attribute
name=
"hide"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.wst.jsdt.launching.baseBrowserLibrary"
/>
<classpathentry
kind=
"output"
path=
""
/>
</classpath>
阮艺博_MyBatis1/阮艺博_MyBatis1/.settings/org.eclipse.jdt.core.prefs
0 → 100644
View file @
2ab62d7e
eclipse.preferences.version=1
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
阮艺博_MyBatis1/阮艺博_MyBatis1/.settings/org.eclipse.m2e.core.prefs
0 → 100644
View file @
2ab62d7e
activeProfiles=
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
阮艺博_MyBatis1/阮艺博_MyBatis1/.settings/org.eclipse.wst.common.component
0 → 100644
View file @
2ab62d7e
<?xml version="1.0" encoding="UTF-8"?>
<project-modules
id=
"moduleCoreId"
project-version=
"1.5.0"
>
<?xml version="1.0" encoding="UTF-8"?>
<project-modules
id=
"moduleCoreId"
project-version=
"1.5.0"
>
<wb-module
deploy-name=
"MyBatisTest"
>
<wb-resource
deploy-path=
"/"
source-path=
"/target/m2e-wtp/web-resources"
/>
<wb-resource
deploy-path=
"/"
source-path=
"/src/main/webapp"
tag=
"defaultRootSource"
/>
<wb-resource
deploy-path=
"/WEB-INF/classes"
source-path=
"/src/main/java"
/>
<wb-resource
deploy-path=
"/WEB-INF/classes"
source-path=
"/src/main/resources"
/>
<wb-resource
deploy-path=
"/WEB-INF/classes"
source-path=
"/src/test/java"
/>
<property
name=
"context-root"
value=
"MyBatisTest"
/>
<property
name=
"java-output-path"
value=
"/MyBatisTest/target/classes"
/>
</wb-module>
</project-modules>
阮艺博_MyBatis1/阮艺博_MyBatis1/.settings/org.eclipse.wst.common.project.facet.core.xml
0 → 100644
View file @
2ab62d7e
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed
facet=
"wst.jsdt.web"
/>
<installed
facet=
"java"
version=
"1.8"
/>
<installed
facet=
"jst.web"
version=
"2.3"
/>
<installed
facet=
"wst.jsdt.web"
version=
"1.0"
/>
</faceted-project>
阮艺博_MyBatis1/阮艺博_MyBatis1/.settings/org.eclipse.wst.jsdt.ui.superType.container
0 → 100644
View file @
2ab62d7e
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
阮艺博_MyBatis1/阮艺博_MyBatis1/.settings/org.eclipse.wst.jsdt.ui.superType.name
0 → 100644
View file @
2ab62d7e
Window
Window
\ No newline at end of file
阮艺博_MyBatis1/阮艺博_MyBatis1/.settings/org.eclipse.wst.validation.prefs
0 → 100644
View file @
2ab62d7e
disabled=06target
disabled=06target
eclipse.preferences.version=1
阮艺博_MyBatis1/阮艺博_MyBatis1/pom.xml
0 → 100644
View file @
2ab62d7e
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
MyBatisTest
</groupId>
<artifactId>
MyBatisTest
</artifactId>
<packaging>
war
</packaging>
<version>
0.0.1-SNAPSHOT
</version>
<name>
MyBatisTest Maven Webapp
</name>
<url>
http://maven.apache.org
</url>
<dependencies>
<dependency>
<groupId>
org.mybatis
</groupId>
<artifactId>
mybatis
</artifactId>
<version>
3.5.3
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.16
</version>
</dependency>
<dependency>
<groupId>
org.json
</groupId>
<artifactId>
json
</artifactId>
<version>
20190722
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
3.8.1
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<finalName>
MyBatisTest
</finalName>
</build>
</project>
阮艺博_MyBatis1/阮艺博_MyBatis1/src/main/java/entity/Test0Entity.java
0 → 100644
View file @
2ab62d7e
package
entity
;
package
entity
;
import
java.io.Serializable
;
import
org.json.JSONObject
;
public
class
Test0Entity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
4224058240682609248L
;
private
String
id
;
private
JSONObject
json
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
JSONObject
getJson
()
{
return
json
;
}
public
void
setJson
(
JSONObject
json
)
{
this
.
json
=
json
;
}
}
阮艺博_MyBatis1/阮艺博_MyBatis1/src/main/java/handler/TypeJsonHandler.java
0 → 100644
View file @
2ab62d7e
package
handler
;
package
handler
;
import
java.sql.CallableStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
org.apache.ibatis.type.BaseTypeHandler
;
import
org.apache.ibatis.type.JdbcType
;
import
org.apache.ibatis.type.MappedJdbcTypes
;
import
org.json.JSONObject
;
@MappedJdbcTypes
(
JdbcType
.
VARCHAR
)
public
class
TypeJsonHandler
extends
BaseTypeHandler
<
JSONObject
>
{
@Override
public
void
setNonNullParameter
(
PreparedStatement
ps
,
int
i
,
JSONObject
parameter
,
JdbcType
jdbcType
)
throws
SQLException
{
if
(
parameter
!=
null
){
ps
.
setString
(
i
,
parameter
.
toString
());
}
}
@Override
public
JSONObject
getNullableResult
(
ResultSet
rs
,
String
columnName
)
throws
SQLException
{
String
value
=
rs
.
getString
(
columnName
);
if
(
value
!=
null
)
{
try
{
return
new
JSONObject
(
value
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
null
;
}
@Override
public
JSONObject
getNullableResult
(
ResultSet
rs
,
int
columnIndex
)
throws
SQLException
{
return
null
;
}
@Override
public
JSONObject
getNullableResult
(
CallableStatement
cs
,
int
columnIndex
)
throws
SQLException
{
// TODO Auto-generated method stub
return
null
;
}
}
阮艺博_MyBatis1/阮艺博_MyBatis1/src/main/java/mapper/Test0Mapper.java
0 → 100644
View file @
2ab62d7e
package
mapper
;
package
mapper
;
import
org.apache.ibatis.annotations.Insert
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.json.JSONObject
;
import
entity.Test0Entity
;
public
interface
Test0Mapper
{
@Select
(
"SELECT * FROM TEST0 WHERE id = #{id}"
)
Test0Entity
selectTest0Entity
(
long
id
);
@Insert
(
"INSERT INTO TEST0 VALUES(#{id}, #{json})"
)
int
insertTest0Entity
(
@Param
(
"id"
)
long
id
,
@Param
(
"json"
)
JSONObject
json
);
}
阮艺博_MyBatis1/阮艺博_MyBatis1/src/main/java/test/MyBatisTest0.java
0 → 100644
View file @
2ab62d7e
package
test
;
package
test
;
import
java.io.InputStream
;
import
java.util.Date
;
import
org.apache.ibatis.io.Resources
;
import
org.apache.ibatis.session.ExecutorType
;
import
org.apache.ibatis.session.SqlSession
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.session.SqlSessionFactoryBuilder
;
import
org.apache.tomcat.util.http.fileupload.IOUtils
;
import
org.json.JSONObject
;
import
entity.Test0Entity
;
import
mapper.Test0Mapper
;
public
class
MyBatisTest0
{
public
static
void
main
(
String
[]
args
)
{
String
resource
=
"mybatis-config.xml"
;
InputStream
inputStream
=
null
;
SqlSession
session
=
null
;
try
{
inputStream
=
Resources
.
getResourceAsStream
(
resource
);
SqlSessionFactory
sqlSessionFactory
=
new
SqlSessionFactoryBuilder
().
build
(
inputStream
);
session
=
sqlSessionFactory
.
openSession
(
ExecutorType
.
BATCH
,
false
);
Test0Mapper
mapper
=
session
.
getMapper
(
Test0Mapper
.
class
);
Date
s
=
new
Date
();
// 批量导入
for
(
int
i
=
1
;
i
<=
1000
;
i
++)
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"name"
,
"花花"
+
i
);
mapper
.
insertTest0Entity
(
i
,
json
);
if
(
i
%
100
==
0
)
{
session
.
flushStatements
();
session
.
commit
();
}
}
session
.
commit
();
Date
e
=
new
Date
();
System
.
out
.
println
(
e
.
getTime
()
-
s
.
getTime
());
// 查询
Test0Entity
test0
=
mapper
.
selectTest0Entity
(
1
);
System
.
out
.
println
(
test0
.
getId
()
+
": "
+
test0
.
getJson
().
getString
(
"name"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
IOUtils
.
closeQuietly
(
inputStream
);
IOUtils
.
closeQuietly
(
session
);
}
}
}
阮艺博_MyBatis1/阮艺博_MyBatis1/src/main/resources/db.properties
0 → 100644
View file @
2ab62d7e
driver
=
com.mysql.cj.jdbc.Driver
driver
=
com.mysql.cj.jdbc.Driver
url
=
jdbc:mysql://localhost:3306/mybatis_test
username
=
root
password
=
root
阮艺博_MyBatis1/阮艺博_MyBatis1/src/main/resources/mybatis-config.xml
0 → 100644
View file @
2ab62d7e
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties
resource=
"db.properties"
></properties>
<typeHandlers>
<typeHandler
javaType=
"org.json.JSONObject"
jdbcType=
"VARCHAR"
handler=
"handler.TypeJsonHandler"
/>
</typeHandlers>
<environments
default=
"development"
>
<environment
id=
"development"
>
<transactionManager
type=
"JDBC"
/>
<dataSource
type=
"POOLED"
>
<property
name=
"driver"
value=
"${driver}"
/>
<property
name=
"url"
value=
"${url}"
/>
<property
name=
"username"
value=
"${username}"
/>
<property
name=
"password"
value=
"${password}"
/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper
class=
"mapper.Test0Mapper"
/>
</mappers>
</configuration>
\ No newline at end of file
阮艺博_MyBatis1/阮艺博_MyBatis1/src/main/webapp/WEB-INF/web.xml
0 → 100644
View file @
2ab62d7e
<!DOCTYPE web-app PUBLIC
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>
Archetype Created Web Application
</display-name>
</web-app>
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