Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
Mybatis Jpa Extra
提交
91c26db0
M
Mybatis Jpa Extra
项目概览
MaxKey单点登录官方(MaxKeyTop)
/
Mybatis Jpa Extra
8 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Mybatis Jpa Extra
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
91c26db0
编写于
5月 30, 2020
作者:
MaxKey单点登录官方
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mybatis-jpa-extra-2.0
mybatis-jpa-extra-2.0
上级
b60c2c63
变更
48
隐藏空白更改
内联
并排
Showing
48 changed file
with
1275 addition
and
903 deletion
+1275
-903
mybatis-jpa-extra-2.1-api-2.0.jar
mybatis-jpa-extra-2.1-api-2.0.jar
+0
-0
mybatis-jpa-extra-2.1-api/.gitignore
mybatis-jpa-extra-2.1-api/.gitignore
+0
-1
mybatis-jpa-extra-2.1-api/.settings/org.springframework.ide.eclipse.prefs
...a-2.1-api/.settings/org.springframework.ide.eclipse.prefs
+0
-2
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/Column.java
...extra-2.1-api/src/main/java/javax/persistence/Column.java
+0
-122
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/GeneratedValue.java
...1-api/src/main/java/javax/persistence/GeneratedValue.java
+0
-79
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/GenerationType.java
...1-api/src/main/java/javax/persistence/GenerationType.java
+0
-56
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/Id.java
...jpa-extra-2.1-api/src/main/java/javax/persistence/Id.java
+0
-55
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/Index.java
...-extra-2.1-api/src/main/java/javax/persistence/Index.java
+0
-68
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/Table.java
...-extra-2.1-api/src/main/java/javax/persistence/Table.java
+0
-80
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/UniqueConstraint.java
...api/src/main/java/javax/persistence/UniqueConstraint.java
+0
-52
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/package-info.java
...2.1-api/src/main/java/javax/persistence/package-info.java
+0
-8
mybatis-jpa-extra-2.1.jar
mybatis-jpa-extra-2.1.jar
+0
-0
mybatis-jpa-extra-core/pom.xml
mybatis-jpa-extra-core/pom.xml
+2
-6
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/MapperMetadata.java
...va/org/apache/mybatis/jpa/persistence/MapperMetadata.java
+114
-0
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/MapperSqlProvider.java
...org/apache/mybatis/jpa/persistence/MapperSqlProvider.java
+69
-317
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/provider/SqlProviderDelete.java
...e/mybatis/jpa/persistence/provider/SqlProviderDelete.java
+61
-0
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/provider/SqlProviderInsert.java
...e/mybatis/jpa/persistence/provider/SqlProviderInsert.java
+69
-0
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/provider/SqlProviderQuery.java
...he/mybatis/jpa/persistence/provider/SqlProviderQuery.java
+119
-0
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/provider/SqlProviderUpdate.java
...e/mybatis/jpa/persistence/provider/SqlProviderUpdate.java
+54
-0
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/provider/package-info.java
...apache/mybatis/jpa/persistence/provider/package-info.java
+1
-0
mybatis-jpa-extra-core/src/test/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
...t/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
+2
-0
mybatis-jpa-extra-spring-boot-starter-2.0.jar
mybatis-jpa-extra-spring-boot-starter-2.0.jar
+0
-0
mybatis-jpa-extra-spring-boot-starter-2.1.jar
mybatis-jpa-extra-spring-boot-starter-2.1.jar
+0
-0
mybatis-jpa-extra-spring-boot-starter/pom.xml
mybatis-jpa-extra-spring-boot-starter/pom.xml
+6
-7
mybatis-jpa-extra-test/.classpath
mybatis-jpa-extra-test/.classpath
+33
-28
mybatis-jpa-extra-test/.project
mybatis-jpa-extra-test/.project
+1
-6
mybatis-jpa-extra-test/.settings/org.eclipse.core.resources.prefs
...jpa-extra-test/.settings/org.eclipse.core.resources.prefs
+5
-4
mybatis-jpa-extra-test/.settings/org.eclipse.jdt.core.prefs
mybatis-jpa-extra-test/.settings/org.eclipse.jdt.core.prefs
+8
-0
mybatis-jpa-extra-test/.settings/org.eclipse.m2e.core.prefs
mybatis-jpa-extra-test/.settings/org.eclipse.m2e.core.prefs
+0
-0
mybatis-jpa-extra-test/pom.xml
mybatis-jpa-extra-test/pom.xml
+12
-10
mybatis-jpa-extra-test/src/main/java/org/apache/mybatis/jpa/test/dao/persistence/StudentsMapper.java
...ache/mybatis/jpa/test/dao/persistence/StudentsMapper.java
+0
-0
mybatis-jpa-extra-test/src/main/java/org/apache/mybatis/jpa/test/dao/service/StudentsService.java
.../apache/mybatis/jpa/test/dao/service/StudentsService.java
+0
-0
mybatis-jpa-extra-test/src/main/java/org/apache/mybatis/jpa/test/domain/DemoDomain.java
...n/java/org/apache/mybatis/jpa/test/domain/DemoDomain.java
+0
-0
mybatis-jpa-extra-test/src/main/java/org/apache/mybatis/jpa/test/domain/Students.java
...ain/java/org/apache/mybatis/jpa/test/domain/Students.java
+0
-0
mybatis-jpa-extra-test/src/test/java/org/apache/mybatis/jpa/test/ApplicationRunner.properties
.../org/apache/mybatis/jpa/test/ApplicationRunner.properties
+0
-0
mybatis-jpa-extra-test/src/test/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
...t/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
+152
-0
mybatis-jpa-extra-test/src/test/java/org/apache/mybatis/jpa/test/SerialGeneratorTest.java
...java/org/apache/mybatis/jpa/test/SerialGeneratorTest.java
+19
-0
mybatis-jpa-extra-test/src/test/java/org/apache/mybatis/jpa/test/UUIDHexGeneratorTest.java
...ava/org/apache/mybatis/jpa/test/UUIDHexGeneratorTest.java
+18
-0
mybatis-jpa-extra-test/src/test/resources/config/applicationConfig.properties
...st/src/test/resources/config/applicationConfig.properties
+29
-0
mybatis-jpa-extra-test/src/test/resources/log4j2.xml
mybatis-jpa-extra-test/src/test/resources/log4j2.xml
+22
-0
mybatis-jpa-extra-test/src/test/resources/org/apache/mybatis/jpa/test/dao/persistence/xml/mysql/StudentsMapper.xml
...tis/jpa/test/dao/persistence/xml/mysql/StudentsMapper.xml
+74
-0
mybatis-jpa-extra-test/src/test/resources/org/apache/mybatis/jpa/test/dao/persistence/xml/oracle/StudentsMapper1.xml
...s/jpa/test/dao/persistence/xml/oracle/StudentsMapper1.xml
+70
-0
mybatis-jpa-extra-test/src/test/resources/spring/applicationContext-database.xml
...src/test/resources/spring/applicationContext-database.xml
+40
-0
mybatis-jpa-extra-test/src/test/resources/spring/applicationContext-persist.xml
.../src/test/resources/spring/applicationContext-persist.xml
+78
-0
mybatis-jpa-extra-test/src/test/resources/spring/applicationContext.xml
...tra-test/src/test/resources/spring/applicationContext.xml
+42
-0
mybatis-jpa-extra-test/src/test/resources/students-mysql.sql
mybatis-jpa-extra-test/src/test/resources/students-mysql.sql
+83
-0
mybatis-jpa-extra-test/src/test/resources/students-oracle.sql
...tis-jpa-extra-test/src/test/resources/students-oracle.sql
+81
-0
pom.xml
pom.xml
+11
-2
未找到文件。
mybatis-jpa-extra-2.1-api-2.0.jar
已删除
100644 → 0
浏览文件 @
b60c2c63
文件已删除
mybatis-jpa-extra-2.1-api/.gitignore
已删除
100644 → 0
浏览文件 @
b60c2c63
/target/
mybatis-jpa-extra-2.1-api/.settings/org.springframework.ide.eclipse.prefs
已删除
100644 → 0
浏览文件 @
b60c2c63
boot.validation.initialized=true
eclipse.preferences.version=1
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/Column.java
已删除
100644 → 0
浏览文件 @
b60c2c63
/*******************************************************************************
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Linda DeMichiel - Java Persistence 2.1
* Linda DeMichiel - Java Persistence 2.0
*
******************************************************************************/
package
javax.persistence
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Retention
;
import
static
java
.
lang
.
annotation
.
ElementType
.
METHOD
;
import
static
java
.
lang
.
annotation
.
ElementType
.
FIELD
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
/**
* Specifies the mapped column for a persistent property or field.
* If no <code>Column</code> annotation is specified, the default values apply.
*
* <blockquote><pre>
* Example 1:
*
* @Column(name="DESC", nullable=false, length=512)
* public String getDescription() { return description; }
*
* Example 2:
*
* @Column(name="DESC",
* columnDefinition="CLOB NOT NULL",
* table="EMP_DETAIL")
* @Lob
* public String getDescription() { return description; }
*
* Example 3:
*
* @Column(name="ORDER_COST", updatable=false, precision=12, scale=2)
* public BigDecimal getCost() { return cost; }
*
* </pre></blockquote>
*
*
* @since Java Persistence 1.0
*/
@Target
({
METHOD
,
FIELD
})
@Retention
(
RUNTIME
)
public
@interface
Column
{
/**
* (Optional) The name of the column. Defaults to
* the property or field name.
*/
String
name
()
default
""
;
/**
* (Optional) Whether the column is a unique key. This is a
* shortcut for the <code>UniqueConstraint</code> annotation at the table
* level and is useful for when the unique key constraint
* corresponds to only a single column. This constraint applies
* in addition to any constraint entailed by primary key mapping and
* to constraints specified at the table level.
*/
boolean
unique
()
default
false
;
/**
* (Optional) Whether the database column is nullable.
*/
boolean
nullable
()
default
true
;
/**
* (Optional) Whether the column is included in SQL INSERT
* statements generated by the persistence provider.
*/
boolean
insertable
()
default
true
;
/**
* (Optional) Whether the column is included in SQL UPDATE
* statements generated by the persistence provider.
*/
boolean
updatable
()
default
true
;
/**
* (Optional) The SQL fragment that is used when
* generating the DDL for the column.
* <p> Defaults to the generated SQL to create a
* column of the inferred type.
*/
String
columnDefinition
()
default
""
;
/**
* (Optional) The name of the table that contains the column.
* If absent the column is assumed to be in the primary table.
*/
String
table
()
default
""
;
/**
* (Optional) The column length. (Applies only if a
* string-valued column is used.)
*/
int
length
()
default
255
;
/**
* (Optional) The precision for a decimal (exact numeric)
* column. (Applies only if a decimal column is used.)
* Value must be set by developer if used when generating
* the DDL for the column.
*/
int
precision
()
default
0
;
/**
* (Optional) The scale for a decimal (exact numeric) column.
* (Applies only if a decimal column is used.)
*/
int
scale
()
default
0
;
}
\ No newline at end of file
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/GeneratedValue.java
已删除
100644 → 0
浏览文件 @
b60c2c63
/*******************************************************************************
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Linda DeMichiel - Java Persistence 2.1
* Linda DeMichiel - Java Persistence 2.0
*
******************************************************************************/
package
javax.persistence
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Retention
;
import
static
java
.
lang
.
annotation
.
ElementType
.
FIELD
;
import
static
java
.
lang
.
annotation
.
ElementType
.
METHOD
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
import
static
javax
.
persistence
.
GenerationType
.
AUTO
;
/**
* Provides for the specification of generation strategies for the
* values of primary keys.
*
* <p> The <code>GeneratedValue</code> annotation
* may be applied to a primary key property or field of an entity or
* mapped superclass in conjunction with the {@link Id} annotation.
* The use of the <code>GeneratedValue</code> annotation is only
* required to be supported for simple primary keys. Use of the
* <code>GeneratedValue</code> annotation is not supported for derived
* primary keys.
*
* <pre>
*
* Example 1:
*
* @Id
* @GeneratedValue(strategy=SEQUENCE, generator="CUST_SEQ")
* @Column(name="CUST_ID")
* public Long getId() { return id; }
*
* Example 2:
*
* @Id
* @GeneratedValue(strategy=TABLE, generator="CUST_GEN")
* @Column(name="CUST_ID")
* Long id;
* </pre>
*
* @see Id
* @see TableGenerator
* @see SequenceGenerator
*
* @since Java Persistence 1.0
*/
@Target
({
METHOD
,
FIELD
})
@Retention
(
RUNTIME
)
public
@interface
GeneratedValue
{
/**
* (Optional) The primary key generation strategy
* that the persistence provider must use to
* generate the annotated entity primary key.
*/
GenerationType
strategy
()
default
AUTO
;
/**
* (Optional) The name of the primary key generator
* to use as specified in the {@link SequenceGenerator}
* or {@link TableGenerator} annotation.
* <p> Defaults to the id generator supplied by persistence provider.
*/
String
generator
()
default
""
;
}
\ No newline at end of file
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/GenerationType.java
已删除
100644 → 0
浏览文件 @
b60c2c63
/*******************************************************************************
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Linda DeMichiel - Java Persistence 2.1
* Linda DeMichiel - Java Persistence 2.0
*
******************************************************************************/
package
javax.persistence
;
/**
* Defines the types of primary key generation strategies.
*
* @see GeneratedValue
*
* @since Java Persistence 1.0
*/
public
enum
GenerationType
{
/**
* Indicates that the persistence provider must assign
* primary keys for the entity using an underlying
* database table to ensure uniqueness.
*/
TABLE
,
/**
* Indicates that the persistence provider must assign
* primary keys for the entity using a database sequence.
*/
SEQUENCE
,
/**
* Indicates that the persistence provider must assign
* primary keys for the entity using a database identity column.
*/
IDENTITY
,
/**
* Indicates that the persistence provider should pick an
* appropriate strategy for the particular database. The
* <code>AUTO</code> generation strategy may expect a database
* resource to exist, or it may attempt to create one. A vendor
* may provide documentation on how to create such resources
* in the event that it does not support schema generation
* or cannot create the schema resource at runtime.
*/
AUTO
}
\ No newline at end of file
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/Id.java
已删除
100644 → 0
浏览文件 @
b60c2c63
/*******************************************************************************
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Linda DeMichiel - Java Persistence 2.1
* Linda DeMichiel - Java Persistence 2.0
*
******************************************************************************/
package
javax.persistence
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Retention
;
import
static
java
.
lang
.
annotation
.
ElementType
.
FIELD
;
import
static
java
.
lang
.
annotation
.
ElementType
.
METHOD
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
/**
* Specifies the primary key of an entity.
* The field or property to which the <code>Id</code> annotation is applied
* should be one of the following types: any Java primitive type;
* any primitive wrapper type;
* <code>String</code>;
* <code>java.util.Date</code>;
* <code>java.sql.Date</code>;
* <code>java.math.BigDecimal</code>;
* <code>java.math.BigInteger</code>.
*
* <p>The mapped column for the primary key of the entity is assumed
* to be the primary key of the primary table. If no <code>Column</code> annotation
* is specified, the primary key column name is assumed to be the name
* of the primary key property or field.
*
* <pre>
* Example:
*
* @Id
* public Long getId() { return id; }
* </pre>
*
* @see Column
* @see GeneratedValue
*
* @since Java Persistence 1.0
*/
@Target
({
METHOD
,
FIELD
})
@Retention
(
RUNTIME
)
public
@interface
Id
{}
\ No newline at end of file
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/Index.java
已删除
100644 → 0
浏览文件 @
b60c2c63
/*******************************************************************************
* Copyright (c) 2011 - 2013 Oracle Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Linda DeMichiel - Java Persistence 2.1
*
******************************************************************************/
package
javax.persistence
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Target
;
/**
* Used in schema generation to specify creation of an index.
* <p>
* Note that it is not necessary to specify an index for a primary key,
* as the primary key index will be created automatically.
*
* <p>
* The syntax of the <code>columnList</code> element is a
* <code>column_list</code>, as follows:
*
* <pre>
* column::= index_column [,index_column]*
* index_column::= column_name [ASC | DESC]
* </pre>
*
* <p> If <code>ASC</code> or <code>DESC</code> is not specified,
* <code>ASC</code> (ascending order) is assumed.
*
* @see Table
* @see SecondaryTable
* @see CollectionTable
* @see JoinTable
* @see TableGenerator
*
* @since Java Persistence 2.1
*
*/
@Target
({})
@Retention
(
RUNTIME
)
public
@interface
Index
{
/**
* (Optional) The name of the index; defaults to a provider-generated name.
*/
String
name
()
default
""
;
/**
* (Required) The names of the columns to be included in the index,
* in order.
*/
String
columnList
();
/**
* (Optional) Whether the index is unique.
*/
boolean
unique
()
default
false
;
}
\ No newline at end of file
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/Table.java
已删除
100644 → 0
浏览文件 @
b60c2c63
/*******************************************************************************
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Linda DeMichiel - Java Persistence 2.1
* Linda DeMichiel - Java Persistence 2.0
*
******************************************************************************/
package
javax.persistence
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Retention
;
import
static
java
.
lang
.
annotation
.
ElementType
.
TYPE
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
/**
* Specifies the primary table for the annotated entity. Additional
* tables may be specified using {@link SecondaryTable} or {@link
* SecondaryTables} annotation.
*
* <p> If no <code>Table</code> annotation is specified for an entity
* class, the default values apply.
*
* <pre>
* Example:
*
* @Entity
* @Table(name="CUST", schema="RECORDS")
* public class Customer { ... }
* </pre>
*
* @since Java Persistence 1.0
*/
@Target
(
TYPE
)
@Retention
(
RUNTIME
)
public
@interface
Table
{
/**
* (Optional) The name of the table.
* <p> Defaults to the entity name.
*/
String
name
()
default
""
;
/** (Optional) The catalog of the table.
* <p> Defaults to the default catalog.
*/
String
catalog
()
default
""
;
/** (Optional) The schema of the table.
* <p> Defaults to the default schema for user.
*/
String
schema
()
default
""
;
/**
* (Optional) Unique constraints that are to be placed on
* the table. These are only used if table generation is in
* effect. These constraints apply in addition to any constraints
* specified by the <code>Column</code> and <code>JoinColumn</code>
* annotations and constraints entailed by primary key mappings.
* <p> Defaults to no additional constraints.
*/
UniqueConstraint
[]
uniqueConstraints
()
default
{};
/**
* (Optional) Indexes for the table. These are only used if
* table generation is in effect. Note that it is not necessary
* to specify an index for a primary key, as the primary key
* index will be created automatically.
*
* @since Java Persistence 2.1
*/
Index
[]
indexes
()
default
{};
}
\ No newline at end of file
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/UniqueConstraint.java
已删除
100644 → 0
浏览文件 @
b60c2c63
/*******************************************************************************
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Linda DeMichiel - Java Persistence 2.1
* Linda DeMichiel - Java Persistence 2.0
*
******************************************************************************/
package
javax.persistence
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Retention
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
/**
* Specifies that a unique constraint is to be included in
* the generated DDL for a primary or secondary table.
*
* <pre>
* Example:
* @Entity
* @Table(
* name="EMPLOYEE",
* uniqueConstraints=
* @UniqueConstraint(columnNames={"EMP_ID", "EMP_NAME"})
* )
* public class Employee { ... }
* </pre>
*
* @since Java Persistence 1.0
*/
@Target
({})
@Retention
(
RUNTIME
)
public
@interface
UniqueConstraint
{
/** (Optional) Constraint name. A provider-chosen name will be chosen
* if a name is not specified.
*
* @since Java Persistence 2.0
*/
String
name
()
default
""
;
/** (Required) An array of the column names that make up the constraint. */
String
[]
columnNames
();
}
\ No newline at end of file
mybatis-jpa-extra-2.1-api/src/main/java/javax/persistence/package-info.java
已删除
100644 → 0
浏览文件 @
b60c2c63
/**
*
*/
/**
* @author Administrator
*
*/
package
javax.persistence
;
\ No newline at end of file
mybatis-jpa-extra-2.
0
.jar
→
mybatis-jpa-extra-2.
1
.jar
浏览文件 @
91c26db0
无法预览此类型文件
mybatis-jpa-extra-core/pom.xml
浏览文件 @
91c26db0
...
...
@@ -4,7 +4,7 @@
<parent>
<groupId>
mybatis-jpa-extra
</groupId>
<artifactId>
mybatis-jpa-extra-parent
</artifactId>
<version>
2.0
</version>
<version>
${extra.version}
</version>
</parent>
<artifactId>
mybatis-jpa-extra
</artifactId>
...
...
@@ -13,11 +13,7 @@
<dependencies>
<dependency>
<groupId>
mybatis-jpa-extra
</groupId>
<artifactId>
mybatis-jpa-extra-2.1-api
</artifactId>
<version>
2.0
</version>
</dependency>
</dependencies>
<build>
<testResources>
...
...
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/MapperMetadata.java
0 → 100644
浏览文件 @
91c26db0
/**
*
*/
package
org.apache.mybatis.jpa.persistence
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
javax.persistence.Column
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
org.apache.mybatis.jpa.id.IdentifierGeneratorFactory
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author Crystal.Sea
*
*/
public
class
MapperMetadata
<
T
extends
JpaBaseDomain
>{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
MapperMetadata
.
class
);
public
static
class
SQL_TYPE
{
public
static
String
GET_SQL
=
"_GET_SQL"
;
public
static
String
FINDALL_SQL
=
"_FINDALL_SQL"
;
public
static
String
REMOVE_SQL
=
"_REMOVE_SQL"
;
}
public
static
String
ENTITY_CLASS
=
"entityClass"
;
/**
* 表名和字段名
*/
public
static
boolean
TABLE_COLUMN_UPCASE
=
true
;
public
transient
static
ConcurrentMap
<
String
,
List
<
FieldColumnMapper
>>
fieldsMap
=
new
ConcurrentHashMap
<
String
,
List
<
FieldColumnMapper
>>();
public
transient
static
ConcurrentMap
<
String
,
String
>
sqlsMap
=
new
ConcurrentHashMap
<
String
,
String
>();
public
static
IdentifierGeneratorFactory
identifierGeneratorFactory
=
new
IdentifierGeneratorFactory
();
public
static
String
getTableName
(
Class
<?>
entityClass
)
{
Table
table
=
(
Table
)
entityClass
.
getAnnotation
(
Table
.
class
);
String
tablename
=
""
;
if
(
table
!=
null
)
{
tablename
=
table
.
name
();
}
else
{
tablename
=
entityClass
.
getClass
().
getSimpleName
();
}
return
TABLE_COLUMN_UPCASE
?
tablename
.
toUpperCase
()
:
tablename
;
}
public
static
FieldColumnMapper
getIdColumn
(
String
classSimpleName
)
{
List
<
FieldColumnMapper
>
listFields
=
fieldsMap
.
get
(
classSimpleName
);
FieldColumnMapper
idFieldColumnMapper
=
null
;
for
(
int
i
=
0
;
i
<
listFields
.
size
();
i
++)
{
if
(
listFields
.
get
(
i
).
isIdColumn
())
{
idFieldColumnMapper
=
listFields
.
get
(
i
);
break
;
}
}
return
idFieldColumnMapper
;
}
public
static
void
buildColumnList
(
Class
<?>
entityClass
)
{
if
(
fieldsMap
.
containsKey
(
entityClass
.
getSimpleName
()))
{
//run one time
return
;
}
_logger
.
trace
(
"entityClass "
+
entityClass
);
Field
[]
fields
=
entityClass
.
getDeclaredFields
();
List
<
FieldColumnMapper
>
fieldColumnMapperList
=
new
ArrayList
<
FieldColumnMapper
>(
fields
.
length
);
for
(
Field
field
:
fields
)
{
if
(
field
.
isAnnotationPresent
(
Column
.
class
))
{
FieldColumnMapper
fieldColumnMapper
=
new
FieldColumnMapper
();
fieldColumnMapper
.
setFieldName
(
field
.
getName
());
fieldColumnMapper
.
setFieldType
(
field
.
getType
().
getSimpleName
());
Column
columnAnnotation
=
(
Column
)
field
.
getAnnotation
(
Column
.
class
);
if
(
columnAnnotation
.
name
()
!=
null
&&
!
columnAnnotation
.
name
().
equals
(
""
))
{
fieldColumnMapper
.
setColumnName
(
columnAnnotation
.
name
());
}
else
{
if
(
TABLE_COLUMN_UPCASE
)
{
fieldColumnMapper
.
setColumnName
(
field
.
getName
().
toUpperCase
());
}
else
{
fieldColumnMapper
.
setColumnName
(
field
.
getName
());
}
}
if
(
field
.
isAnnotationPresent
(
Id
.
class
))
{
fieldColumnMapper
.
setIdColumn
(
true
);
}
if
(
field
.
isAnnotationPresent
(
GeneratedValue
.
class
))
{
GeneratedValue
generatedValue
=(
GeneratedValue
)
field
.
getAnnotation
(
GeneratedValue
.
class
);
fieldColumnMapper
.
setGeneratedValue
(
generatedValue
);
}
_logger
.
trace
(
"FieldColumnMapper : "
+
fieldColumnMapper
);
fieldColumnMapperList
.
add
(
fieldColumnMapper
);
}
}
fieldsMap
.
put
(
entityClass
.
getSimpleName
(),
fieldColumnMapperList
);
_logger
.
debug
(
"fieldsMap : "
+
fieldsMap
);
}
}
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/MapperSqlProvider.java
浏览文件 @
91c26db0
/**
*
*/
package
org.apache.mybatis.jpa.persistence
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
javax.persistence.Column
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
org.apache.ibatis.jdbc.SQL
;
import
org.apache.ibatis.mapping.BoundSql
;
import
org.apache.ibatis.mapping.ParameterMapping
;
import
org.apache.mybatis.jpa.PageResultsSqlCache
;
import
org.apache.mybatis.jpa.id.IdentifierGeneratorFactory
;
import
org.apache.mybatis.jpa.util.BeanUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author Crystal.Sea
*
*/
public
class
MapperSqlProvider
<
T
extends
JpaBaseDomain
>{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
MapperSqlProvider
.
class
);
public
static
class
SQL_TYPE
{
public
static
String
GET_SQL
=
"_GET_SQL"
;
public
static
String
FINDALL_SQL
=
"_FINDALL_SQL"
;
public
static
String
REMOVE_SQL
=
"_REMOVE_SQL"
;
}
public
static
String
ENTITY_CLASS
=
"entityClass"
;
/**
* 表名和字段名
*/
private
static
boolean
TABLE_COLUMN_UPCASE
=
true
;
private
transient
static
ConcurrentMap
<
String
,
List
<
FieldColumnMapper
>>
fieldsMap
=
new
ConcurrentHashMap
<
String
,
List
<
FieldColumnMapper
>>();
private
transient
static
ConcurrentMap
<
String
,
String
>
sqlsMap
=
new
ConcurrentHashMap
<
String
,
String
>();
private
static
IdentifierGeneratorFactory
identifierGeneratorFactory
=
new
IdentifierGeneratorFactory
();
public
String
get
(
Map
<
String
,
Object
>
parametersMap
)
{
Class
<?>
entityClass
=(
Class
<?>)
parametersMap
.
get
(
ENTITY_CLASS
);
buildColumnList
(
entityClass
);
if
(
sqlsMap
.
containsKey
(
getTableName
(
entityClass
)
+
SQL_TYPE
.
GET_SQL
))
{
return
sqlsMap
.
get
(
getTableName
(
entityClass
)
+
SQL_TYPE
.
GET_SQL
);
}
FieldColumnMapper
idFieldColumnMapper
=
getIdColumn
(
entityClass
.
getSimpleName
());
SQL
sql
=
new
SQL
();
sql
.
SELECT
(
" * "
);
sql
.
FROM
(
getTableName
(
entityClass
));
sql
.
WHERE
(
idFieldColumnMapper
.
getColumnName
()+
" = #{"
+
idFieldColumnMapper
.
getFieldName
()+
"}"
);
String
getSql
=
sql
.
toString
();
_logger
.
trace
(
"Get SQL \n"
+
getSql
);
sqlsMap
.
put
(
getTableName
(
entityClass
)
+
SQL_TYPE
.
GET_SQL
,
getSql
);
return
getSql
;
}
public
String
findAll
(
Map
<
String
,
Object
>
parametersMap
)
{
Class
<?>
entityClass
=(
Class
<?>)
parametersMap
.
get
(
ENTITY_CLASS
);
buildColumnList
(
entityClass
);
if
(
sqlsMap
.
containsKey
(
getTableName
(
entityClass
)
+
SQL_TYPE
.
FINDALL_SQL
))
{
return
sqlsMap
.
get
(
getTableName
(
entityClass
)
+
SQL_TYPE
.
FINDALL_SQL
);
}
SQL
sql
=
new
SQL
();
sql
.
SELECT
(
" * "
);
sql
.
FROM
(
getTableName
(
entityClass
));
String
findAllSql
=
sql
.
toString
();
_logger
.
trace
(
"Find All SQL \n"
+
findAllSql
);
sqlsMap
.
put
(
getTableName
(
entityClass
)
+
SQL_TYPE
.
FINDALL_SQL
,
findAllSql
);
return
findAllSql
;
}
public
String
remove
(
Map
<
String
,
Object
>
parametersMap
)
{
Class
<?>
entityClass
=(
Class
<?>)
parametersMap
.
get
(
ENTITY_CLASS
);
buildColumnList
(
entityClass
);
if
(
sqlsMap
.
containsKey
(
getTableName
(
entityClass
)
+
SQL_TYPE
.
REMOVE_SQL
))
{
return
sqlsMap
.
get
(
getTableName
(
entityClass
)
+
SQL_TYPE
.
REMOVE_SQL
);
}
FieldColumnMapper
idFieldColumnMapper
=
getIdColumn
((
entityClass
).
getSimpleName
());
SQL
sql
=
new
SQL
();
sql
.
DELETE_FROM
(
getTableName
(
entityClass
));
sql
.
WHERE
(
idFieldColumnMapper
.
getColumnName
()+
" = #{"
+
idFieldColumnMapper
.
getFieldName
()+
",javaType=string,jdbcType=VARCHAR}"
);
String
deleteSql
=
sql
.
toString
();
_logger
.
trace
(
"Delete SQL \n"
+
deleteSql
);
sqlsMap
.
put
(
getTableName
(
entityClass
)
+
SQL_TYPE
.
REMOVE_SQL
,
deleteSql
);
return
deleteSql
;
}
public
String
batchDelete
(
Map
<
String
,
Object
>
parametersMap
)
{
Class
<?>
entityClass
=(
Class
<?>)
parametersMap
.
get
(
ENTITY_CLASS
);
buildColumnList
(
entityClass
);
@SuppressWarnings
(
"unchecked"
)
ArrayList
<
String
>
idValues
=(
ArrayList
<
String
>)
parametersMap
.
get
(
"idList"
);
String
keyValue
=
""
;
for
(
String
value
:
idValues
)
{
keyValue
+=
",'"
+
value
+
"'"
;
}
keyValue
=
keyValue
.
substring
(
1
);
FieldColumnMapper
idFieldColumnMapper
=
getIdColumn
(
entityClass
.
getSimpleName
());
SQL
sql
=
new
SQL
();
sql
.
DELETE_FROM
(
getTableName
(
entityClass
));
sql
.
WHERE
(
idFieldColumnMapper
.
getColumnName
()+
" IN ( "
+
keyValue
+
" )"
);
String
deleteSql
=
sql
.
toString
();
_logger
.
trace
(
"Delete SQL \n"
+
deleteSql
);
sqlsMap
.
put
(
getTableName
(
entityClass
)
+
SQL_TYPE
.
REMOVE_SQL
,
deleteSql
);
return
deleteSql
;
}
/**
* @param entity
* @return insert sql String
*/
public
String
insert
(
T
entity
)
{
buildColumnList
(
entity
.
getClass
());
List
<
FieldColumnMapper
>
listFields
=
fieldsMap
.
get
(
entity
.
getClass
().
getSimpleName
());
SQL
sql
=
new
SQL
();
sql
.
INSERT_INTO
(
getTableName
(
entity
.
getClass
()));
for
(
int
i
=
0
;
i
<
listFields
.
size
();
i
++)
{
FieldColumnMapper
fieldColumnMapper
=
listFields
.
get
(
i
);
if
(
fieldColumnMapper
.
getFieldType
().
equalsIgnoreCase
(
"String"
)
&&
BeanUtil
.
getValue
(
entity
,
fieldColumnMapper
.
getFieldName
())==
null
&&
fieldColumnMapper
.
getGeneratedValue
()==
null
)
{
//skip null field value
}
else
{
if
(
fieldColumnMapper
.
getGeneratedValue
()!=
null
)
{
GeneratedValue
generatedValue
=
listFields
.
get
(
i
).
getGeneratedValue
();
if
(
generatedValue
.
strategy
()==
GenerationType
.
AUTO
)
{
if
(
identifierGeneratorFactory
.
getGeneratorStrategyMap
().
containsKey
(
generatedValue
.
generator
().
toLowerCase
()))
{
BeanUtil
.
set
(
entity
,
fieldColumnMapper
.
getFieldName
(),
identifierGeneratorFactory
.
generate
(
generatedValue
.
generator
().
toLowerCase
()));
sql
.
VALUES
(
fieldColumnMapper
.
getColumnName
(),
"#{"
+
fieldColumnMapper
.
getFieldName
()
+
"}"
);
}
}
else
if
(
generatedValue
.
strategy
()==
GenerationType
.
SEQUENCE
){
sql
.
VALUES
(
fieldColumnMapper
.
getColumnName
(),
generatedValue
.
generator
()+
".NEXTVAL"
);
}
else
if
(
generatedValue
.
strategy
()==
GenerationType
.
IDENTITY
){
//skip
}
else
if
(
generatedValue
.
strategy
()==
GenerationType
.
TABLE
){
//TODO
}
}
else
{
sql
.
VALUES
(
fieldColumnMapper
.
getColumnName
(),
"#{"
+
fieldColumnMapper
.
getFieldName
()
+
"}"
);
}
}
}
_logger
.
trace
(
"Insert SQL : \n"
+
sql
);
return
sql
.
toString
();
}
/**
* @param entity
* @return update sql String
*/
public
String
update
(
T
entity
)
{
buildColumnList
(
entity
.
getClass
());
List
<
FieldColumnMapper
>
listFields
=
fieldsMap
.
get
(
entity
.
getClass
().
getSimpleName
());
SQL
sql
=
new
SQL
();
sql
.
UPDATE
(
getTableName
(
entity
.
getClass
()));
for
(
int
i
=
0
;
i
<
listFields
.
size
();
i
++)
{
FieldColumnMapper
fieldColumnMapper
=
listFields
.
get
(
i
);
if
(
fieldColumnMapper
.
isIdColumn
())
{
continue
;
}
if
(
fieldColumnMapper
.
getFieldType
().
equalsIgnoreCase
(
"String"
)&&
BeanUtil
.
getValue
(
entity
,
fieldColumnMapper
.
getFieldName
())==
null
)
{
//skip null field value
}
else
{
sql
.
SET
(
fieldColumnMapper
.
getColumnName
()
+
"=#{"
+
fieldColumnMapper
.
getFieldName
()
+
"}"
);
}
}
FieldColumnMapper
idFieldColumnMapper
=
getIdColumn
(
entity
.
getClass
().
getSimpleName
());
sql
.
WHERE
(
idFieldColumnMapper
.
getColumnName
()
+
"=#{"
+
idFieldColumnMapper
.
getFieldName
()+
"}"
);
_logger
.
trace
(
"Update SQL : \n"
+
sql
);
return
sql
.
toString
();
}
/**
* @param entity
* @return insert sql String
*/
public
String
queryPageResultsCount
(
T
entity
)
{
JpaPagination
pagination
=(
JpaPagination
)
entity
;
//获取缓存数据
PageResultsSqlCache
pageResultsSqlCache
=
JpaBaseService
.
pageResultsBoundSqlCache
.
get
(
pagination
.
getPageResultSelectUUID
());
String
selectSql
=
pageResultsSqlCache
.
getSql
();
BoundSql
boundSql
=(
BoundSql
)
pageResultsSqlCache
.
getBoundSql
();
StringBuffer
sql
=
new
StringBuffer
();
StringBuffer
countSql
=
new
StringBuffer
();
if
(
boundSql
.
getParameterMappings
()==
null
||
boundSql
.
getParameterMappings
().
isEmpty
())
{
countSql
.
append
(
selectSql
);
}
else
{
for
(
ParameterMapping
parameterMapping:
boundSql
.
getParameterMappings
())
{
countSql
.
append
(
selectSql
.
substring
(
0
,
selectSql
.
indexOf
(
"?"
)));
countSql
.
append
(
"#{"
+
parameterMapping
.
getProperty
()+
"}"
);
selectSql
=
selectSql
.
substring
(
selectSql
.
indexOf
(
"?"
)+
1
);
}
countSql
.
append
(
selectSql
);
}
if
(
countSql
.
toString
().
toUpperCase
().
indexOf
(
"DISTINCT"
)>
0
)
{
sql
.
append
(
"SELECT COUNT(1) COUNTROWS_ FROM ("
).
append
(
countSql
).
append
(
" ) COUNT_TABLE_"
);
}
else
{
sql
.
append
(
"SELECT COUNT(1) COUNTROWS_ "
).
append
(
countSql
.
substring
(
countSql
.
toString
().
toUpperCase
().
indexOf
(
"FROM"
))
);
}
//删除缓存
JpaBaseService
.
pageResultsBoundSqlCache
.
remove
(
pagination
.
getPageResultSelectUUID
());
_logger
.
trace
(
"Count SQL : \n"
+
sql
);
return
sql
.
toString
();
}
public
String
query
(
T
entity
)
{
buildColumnList
(
entity
.
getClass
());
SQL
sql
=
new
SQL
();
sql
.
SELECT
(
" * "
);
sql
.
FROM
(
getTableName
(
entity
.
getClass
()));
for
(
FieldColumnMapper
fieldColumnMapper
:
fieldsMap
.
get
(
entity
.
getClass
().
getSimpleName
()))
{
if
(
fieldColumnMapper
.
getFieldType
().
equalsIgnoreCase
(
"String"
)&&
BeanUtil
.
getValue
(
entity
,
fieldColumnMapper
.
getFieldName
())==
null
)
{
//skip null field value
}
else
{
sql
.
WHERE
(
fieldColumnMapper
.
getColumnName
()
+
"=#{"
+
fieldColumnMapper
.
getFieldName
()
+
"}"
);
}
}
return
sql
.
toString
();
}
public
String
getTableName
(
Class
<?>
entityClass
)
{
Table
table
=
(
Table
)
entityClass
.
getAnnotation
(
Table
.
class
);
String
tablename
=
""
;
if
(
table
!=
null
)
{
tablename
=
table
.
name
();
}
else
{
tablename
=
entityClass
.
getClass
().
getSimpleName
();
}
return
TABLE_COLUMN_UPCASE
?
tablename
.
toUpperCase
()
:
tablename
;
}
public
FieldColumnMapper
getIdColumn
(
String
classSimpleName
)
{
List
<
FieldColumnMapper
>
listFields
=
fieldsMap
.
get
(
classSimpleName
);
FieldColumnMapper
idFieldColumnMapper
=
null
;
for
(
int
i
=
0
;
i
<
listFields
.
size
();
i
++)
{
if
(
listFields
.
get
(
i
).
isIdColumn
())
{
idFieldColumnMapper
=
listFields
.
get
(
i
);
break
;
}
}
return
idFieldColumnMapper
;
}
public
void
buildColumnList
(
Class
<?>
entityClass
)
{
if
(
fieldsMap
.
containsKey
(
entityClass
.
getSimpleName
()))
{
//run one time
return
;
}
_logger
.
trace
(
"entityClass "
+
entityClass
);
Field
[]
fields
=
entityClass
.
getDeclaredFields
();
List
<
FieldColumnMapper
>
fieldColumnMapperList
=
new
ArrayList
<
FieldColumnMapper
>(
fields
.
length
);
for
(
Field
field
:
fields
)
{
if
(
field
.
isAnnotationPresent
(
Column
.
class
))
{
FieldColumnMapper
fieldColumnMapper
=
new
FieldColumnMapper
();
fieldColumnMapper
.
setFieldName
(
field
.
getName
());
fieldColumnMapper
.
setFieldType
(
field
.
getType
().
getSimpleName
());
Column
columnAnnotation
=
(
Column
)
field
.
getAnnotation
(
Column
.
class
);
if
(
columnAnnotation
.
name
()
!=
null
&&
!
columnAnnotation
.
name
().
equals
(
""
))
{
fieldColumnMapper
.
setColumnName
(
columnAnnotation
.
name
());
}
else
{
if
(
TABLE_COLUMN_UPCASE
)
{
fieldColumnMapper
.
setColumnName
(
field
.
getName
().
toUpperCase
());
}
else
{
fieldColumnMapper
.
setColumnName
(
field
.
getName
());
}
}
if
(
field
.
isAnnotationPresent
(
Id
.
class
))
{
fieldColumnMapper
.
setIdColumn
(
true
);
}
if
(
field
.
isAnnotationPresent
(
GeneratedValue
.
class
))
{
GeneratedValue
generatedValue
=(
GeneratedValue
)
field
.
getAnnotation
(
GeneratedValue
.
class
);
fieldColumnMapper
.
setGeneratedValue
(
generatedValue
);
}
_logger
.
trace
(
"FieldColumnMapper : "
+
fieldColumnMapper
);
fieldColumnMapperList
.
add
(
fieldColumnMapper
);
}
}
fieldsMap
.
put
(
entityClass
.
getSimpleName
(),
fieldColumnMapperList
);
_logger
.
debug
(
"fieldsMap : "
+
fieldsMap
);
}
}
/**
*
*/
package
org.apache.mybatis.jpa.persistence
;
import
java.util.Map
;
import
org.apache.mybatis.jpa.persistence.provider.SqlProviderDelete
;
import
org.apache.mybatis.jpa.persistence.provider.SqlProviderInsert
;
import
org.apache.mybatis.jpa.persistence.provider.SqlProviderQuery
;
import
org.apache.mybatis.jpa.persistence.provider.SqlProviderUpdate
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author Crystal.Sea
*
*/
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
class
MapperSqlProvider
<
T
extends
JpaBaseDomain
>{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
MapperSqlProvider
.
class
);
public
String
get
(
Map
<
String
,
Object
>
parametersMap
)
{
return
new
SqlProviderQuery
().
get
(
parametersMap
);
}
public
String
findAll
(
Map
<
String
,
Object
>
parametersMap
)
{
return
new
SqlProviderQuery
().
findAll
(
parametersMap
);
}
public
String
remove
(
Map
<
String
,
Object
>
parametersMap
)
{
return
new
SqlProviderDelete
().
remove
(
parametersMap
);
}
public
String
batchDelete
(
Map
<
String
,
Object
>
parametersMap
)
{
return
new
SqlProviderDelete
().
batchDelete
(
parametersMap
);
}
/**
* @param entity
* @return insert sql String
*/
public
String
insert
(
T
entity
)
{
return
new
SqlProviderInsert
().
insert
(
entity
);
}
/**
* @param entity
* @return update sql String
*/
public
String
update
(
T
entity
)
{
return
new
SqlProviderUpdate
().
update
(
entity
);
}
/**
* @param entity
* @return insert sql String
*/
public
String
queryPageResultsCount
(
T
entity
)
{
return
new
SqlProviderQuery
().
queryPageResultsCount
(
entity
);
}
public
String
query
(
T
entity
)
{
return
new
SqlProviderQuery
().
query
(
entity
);
}
}
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/provider/SqlProviderDelete.java
0 → 100644
浏览文件 @
91c26db0
/**
*
*/
package
org.apache.mybatis.jpa.persistence.provider
;
import
java.util.ArrayList
;
import
java.util.Map
;
import
org.apache.ibatis.jdbc.SQL
;
import
org.apache.mybatis.jpa.persistence.FieldColumnMapper
;
import
org.apache.mybatis.jpa.persistence.JpaBaseDomain
;
import
org.apache.mybatis.jpa.persistence.MapperMetadata
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author Crystal.Sea
*
*/
public
class
SqlProviderDelete
<
T
extends
JpaBaseDomain
>{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
SqlProviderDelete
.
class
);
public
String
remove
(
Map
<
String
,
Object
>
parametersMap
)
{
Class
<?>
entityClass
=(
Class
<?>)
parametersMap
.
get
(
MapperMetadata
.
ENTITY_CLASS
);
MapperMetadata
.
buildColumnList
(
entityClass
);
if
(
MapperMetadata
.
sqlsMap
.
containsKey
(
MapperMetadata
.
getTableName
(
entityClass
)
+
MapperMetadata
.
SQL_TYPE
.
REMOVE_SQL
))
{
return
MapperMetadata
.
sqlsMap
.
get
(
MapperMetadata
.
getTableName
(
entityClass
)
+
MapperMetadata
.
SQL_TYPE
.
REMOVE_SQL
);
}
FieldColumnMapper
idFieldColumnMapper
=
MapperMetadata
.
getIdColumn
((
entityClass
).
getSimpleName
());
SQL
sql
=
new
SQL
();
sql
.
DELETE_FROM
(
MapperMetadata
.
getTableName
(
entityClass
));
sql
.
WHERE
(
idFieldColumnMapper
.
getColumnName
()+
" = #{"
+
idFieldColumnMapper
.
getFieldName
()+
",javaType=string,jdbcType=VARCHAR}"
);
String
deleteSql
=
sql
.
toString
();
_logger
.
trace
(
"Delete SQL \n"
+
deleteSql
);
MapperMetadata
.
sqlsMap
.
put
(
MapperMetadata
.
getTableName
(
entityClass
)
+
MapperMetadata
.
SQL_TYPE
.
REMOVE_SQL
,
deleteSql
);
return
deleteSql
;
}
public
String
batchDelete
(
Map
<
String
,
Object
>
parametersMap
)
{
Class
<?>
entityClass
=(
Class
<?>)
parametersMap
.
get
(
MapperMetadata
.
ENTITY_CLASS
);
MapperMetadata
.
buildColumnList
(
entityClass
);
@SuppressWarnings
(
"unchecked"
)
ArrayList
<
String
>
idValues
=(
ArrayList
<
String
>)
parametersMap
.
get
(
"idList"
);
String
keyValue
=
""
;
for
(
String
value
:
idValues
)
{
keyValue
+=
",'"
+
value
+
"'"
;
}
keyValue
=
keyValue
.
substring
(
1
);
FieldColumnMapper
idFieldColumnMapper
=
MapperMetadata
.
getIdColumn
(
entityClass
.
getSimpleName
());
SQL
sql
=
new
SQL
();
sql
.
DELETE_FROM
(
MapperMetadata
.
getTableName
(
entityClass
));
sql
.
WHERE
(
idFieldColumnMapper
.
getColumnName
()+
" IN ( "
+
keyValue
+
" )"
);
String
deleteSql
=
sql
.
toString
();
_logger
.
trace
(
"Delete SQL \n"
+
deleteSql
);
MapperMetadata
.
sqlsMap
.
put
(
MapperMetadata
.
getTableName
(
entityClass
)
+
MapperMetadata
.
SQL_TYPE
.
REMOVE_SQL
,
deleteSql
);
return
deleteSql
;
}
}
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/provider/SqlProviderInsert.java
0 → 100644
浏览文件 @
91c26db0
/**
*
*/
package
org.apache.mybatis.jpa.persistence.provider
;
import
java.util.List
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
org.apache.ibatis.jdbc.SQL
;
import
org.apache.mybatis.jpa.persistence.FieldColumnMapper
;
import
org.apache.mybatis.jpa.persistence.JpaBaseDomain
;
import
org.apache.mybatis.jpa.persistence.MapperMetadata
;
import
org.apache.mybatis.jpa.util.BeanUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author Crystal.Sea
*
*/
public
class
SqlProviderInsert
<
T
extends
JpaBaseDomain
>{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
SqlProviderInsert
.
class
);
/**
* @param entity
* @return insert sql String
*/
public
String
insert
(
T
entity
)
{
MapperMetadata
.
buildColumnList
(
entity
.
getClass
());
List
<
FieldColumnMapper
>
listFields
=
MapperMetadata
.
fieldsMap
.
get
(
entity
.
getClass
().
getSimpleName
());
SQL
sql
=
new
SQL
();
sql
.
INSERT_INTO
(
MapperMetadata
.
getTableName
(
entity
.
getClass
()));
for
(
int
i
=
0
;
i
<
listFields
.
size
();
i
++)
{
FieldColumnMapper
fieldColumnMapper
=
listFields
.
get
(
i
);
if
(
fieldColumnMapper
.
getFieldType
().
equalsIgnoreCase
(
"String"
)
&&
BeanUtil
.
getValue
(
entity
,
fieldColumnMapper
.
getFieldName
())==
null
&&
fieldColumnMapper
.
getGeneratedValue
()==
null
)
{
//skip null field value
}
else
{
//have GeneratedValue and (value is null or eq "")
if
(
fieldColumnMapper
.
getGeneratedValue
()!=
null
&&
(
BeanUtil
.
get
(
entity
,
fieldColumnMapper
.
getFieldName
())
==
null
||
BeanUtil
.
get
(
entity
,
fieldColumnMapper
.
getFieldName
())
==
""
))
{
GeneratedValue
generatedValue
=
listFields
.
get
(
i
).
getGeneratedValue
();
if
(
generatedValue
.
strategy
()==
GenerationType
.
AUTO
)
{
if
(
MapperMetadata
.
identifierGeneratorFactory
.
getGeneratorStrategyMap
().
containsKey
(
generatedValue
.
generator
().
toLowerCase
()))
{
BeanUtil
.
set
(
entity
,
fieldColumnMapper
.
getFieldName
(),
MapperMetadata
.
identifierGeneratorFactory
.
generate
(
generatedValue
.
generator
().
toLowerCase
()));
sql
.
VALUES
(
fieldColumnMapper
.
getColumnName
(),
"#{"
+
fieldColumnMapper
.
getFieldName
()
+
"}"
);
}
}
else
if
(
generatedValue
.
strategy
()==
GenerationType
.
SEQUENCE
){
sql
.
VALUES
(
fieldColumnMapper
.
getColumnName
(),
generatedValue
.
generator
()+
".NEXTVAL"
);
}
else
if
(
generatedValue
.
strategy
()==
GenerationType
.
IDENTITY
){
//skip
}
else
if
(
generatedValue
.
strategy
()==
GenerationType
.
TABLE
){
//TODO
}
}
else
{
sql
.
VALUES
(
fieldColumnMapper
.
getColumnName
(),
"#{"
+
fieldColumnMapper
.
getFieldName
()
+
"}"
);
}
}
}
_logger
.
trace
(
"Insert SQL : \n"
+
sql
);
return
sql
.
toString
();
}
}
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/provider/SqlProviderQuery.java
0 → 100644
浏览文件 @
91c26db0
/**
*
*/
package
org.apache.mybatis.jpa.persistence.provider
;
import
java.util.Map
;
import
org.apache.ibatis.jdbc.SQL
;
import
org.apache.ibatis.mapping.BoundSql
;
import
org.apache.ibatis.mapping.ParameterMapping
;
import
org.apache.mybatis.jpa.PageResultsSqlCache
;
import
org.apache.mybatis.jpa.persistence.FieldColumnMapper
;
import
org.apache.mybatis.jpa.persistence.JpaBaseDomain
;
import
org.apache.mybatis.jpa.persistence.JpaBaseService
;
import
org.apache.mybatis.jpa.persistence.JpaPagination
;
import
org.apache.mybatis.jpa.persistence.MapperMetadata
;
import
org.apache.mybatis.jpa.persistence.MapperMetadata.SQL_TYPE
;
import
org.apache.mybatis.jpa.util.BeanUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author Crystal.Sea
*
*/
public
class
SqlProviderQuery
<
T
extends
JpaBaseDomain
>{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
SqlProviderQuery
.
class
);
public
String
get
(
Map
<
String
,
Object
>
parametersMap
)
{
Class
<?>
entityClass
=(
Class
<?>)
parametersMap
.
get
(
MapperMetadata
.
ENTITY_CLASS
);
MapperMetadata
.
buildColumnList
(
entityClass
);
if
(
MapperMetadata
.
sqlsMap
.
containsKey
(
MapperMetadata
.
getTableName
(
entityClass
)
+
SQL_TYPE
.
GET_SQL
))
{
return
MapperMetadata
.
sqlsMap
.
get
(
MapperMetadata
.
getTableName
(
entityClass
)
+
SQL_TYPE
.
GET_SQL
);
}
FieldColumnMapper
idFieldColumnMapper
=
MapperMetadata
.
getIdColumn
(
entityClass
.
getSimpleName
());
SQL
sql
=
new
SQL
();
sql
.
SELECT
(
" * "
);
sql
.
FROM
(
MapperMetadata
.
getTableName
(
entityClass
));
sql
.
WHERE
(
idFieldColumnMapper
.
getColumnName
()+
" = #{"
+
idFieldColumnMapper
.
getFieldName
()+
"}"
);
String
getSql
=
sql
.
toString
();
_logger
.
trace
(
"Get SQL \n"
+
getSql
);
MapperMetadata
.
sqlsMap
.
put
(
MapperMetadata
.
getTableName
(
entityClass
)
+
SQL_TYPE
.
GET_SQL
,
getSql
);
return
getSql
;
}
public
String
findAll
(
Map
<
String
,
Object
>
parametersMap
)
{
Class
<?>
entityClass
=(
Class
<?>)
parametersMap
.
get
(
MapperMetadata
.
ENTITY_CLASS
);
MapperMetadata
.
buildColumnList
(
entityClass
);
if
(
MapperMetadata
.
sqlsMap
.
containsKey
(
MapperMetadata
.
getTableName
(
entityClass
)
+
SQL_TYPE
.
FINDALL_SQL
))
{
return
MapperMetadata
.
sqlsMap
.
get
(
MapperMetadata
.
getTableName
(
entityClass
)
+
SQL_TYPE
.
FINDALL_SQL
);
}
SQL
sql
=
new
SQL
();
sql
.
SELECT
(
" * "
);
sql
.
FROM
(
MapperMetadata
.
getTableName
(
entityClass
));
String
findAllSql
=
sql
.
toString
();
_logger
.
trace
(
"Find All SQL \n"
+
findAllSql
);
MapperMetadata
.
sqlsMap
.
put
(
MapperMetadata
.
getTableName
(
entityClass
)
+
SQL_TYPE
.
FINDALL_SQL
,
findAllSql
);
return
findAllSql
;
}
/**
* @param entity
* @return insert sql String
*/
public
String
queryPageResultsCount
(
T
entity
)
{
JpaPagination
pagination
=(
JpaPagination
)
entity
;
//获取缓存数据
PageResultsSqlCache
pageResultsSqlCache
=
JpaBaseService
.
pageResultsBoundSqlCache
.
get
(
pagination
.
getPageResultSelectUUID
());
String
selectSql
=
pageResultsSqlCache
.
getSql
();
BoundSql
boundSql
=(
BoundSql
)
pageResultsSqlCache
.
getBoundSql
();
StringBuffer
sql
=
new
StringBuffer
();
StringBuffer
countSql
=
new
StringBuffer
();
if
(
boundSql
.
getParameterMappings
()==
null
||
boundSql
.
getParameterMappings
().
isEmpty
())
{
countSql
.
append
(
selectSql
);
}
else
{
for
(
ParameterMapping
parameterMapping:
boundSql
.
getParameterMappings
())
{
countSql
.
append
(
selectSql
.
substring
(
0
,
selectSql
.
indexOf
(
"?"
)));
countSql
.
append
(
"#{"
+
parameterMapping
.
getProperty
()+
"}"
);
selectSql
=
selectSql
.
substring
(
selectSql
.
indexOf
(
"?"
)+
1
);
}
countSql
.
append
(
selectSql
);
}
if
(
countSql
.
toString
().
toUpperCase
().
indexOf
(
"DISTINCT"
)>
0
)
{
sql
.
append
(
"SELECT COUNT(1) COUNTROWS_ FROM ("
).
append
(
countSql
).
append
(
" ) COUNT_TABLE_"
);
}
else
{
sql
.
append
(
"SELECT COUNT(1) COUNTROWS_ "
).
append
(
countSql
.
substring
(
countSql
.
toString
().
toUpperCase
().
indexOf
(
"FROM"
))
);
}
//删除缓存
JpaBaseService
.
pageResultsBoundSqlCache
.
remove
(
pagination
.
getPageResultSelectUUID
());
_logger
.
trace
(
"Count SQL : \n"
+
sql
);
return
sql
.
toString
();
}
public
String
query
(
T
entity
)
{
MapperMetadata
.
buildColumnList
(
entity
.
getClass
());
SQL
sql
=
new
SQL
();
sql
.
SELECT
(
" * "
);
sql
.
FROM
(
MapperMetadata
.
getTableName
(
entity
.
getClass
()));
for
(
FieldColumnMapper
fieldColumnMapper
:
MapperMetadata
.
fieldsMap
.
get
(
entity
.
getClass
().
getSimpleName
()))
{
if
(
fieldColumnMapper
.
getFieldType
().
equalsIgnoreCase
(
"String"
)&&
BeanUtil
.
getValue
(
entity
,
fieldColumnMapper
.
getFieldName
())==
null
)
{
//skip null field value
}
else
{
sql
.
WHERE
(
fieldColumnMapper
.
getColumnName
()
+
"=#{"
+
fieldColumnMapper
.
getFieldName
()
+
"}"
);
}
}
return
sql
.
toString
();
}
}
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/provider/SqlProviderUpdate.java
0 → 100644
浏览文件 @
91c26db0
/**
*
*/
package
org.apache.mybatis.jpa.persistence.provider
;
import
java.util.List
;
import
org.apache.ibatis.jdbc.SQL
;
import
org.apache.mybatis.jpa.persistence.FieldColumnMapper
;
import
org.apache.mybatis.jpa.persistence.JpaBaseDomain
;
import
org.apache.mybatis.jpa.persistence.MapperMetadata
;
import
org.apache.mybatis.jpa.util.BeanUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author Crystal.Sea
*
*/
public
class
SqlProviderUpdate
<
T
extends
JpaBaseDomain
>{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
SqlProviderUpdate
.
class
);
/**
* @param entity
* @return update sql String
*/
public
String
update
(
T
entity
)
{
MapperMetadata
.
buildColumnList
(
entity
.
getClass
());
List
<
FieldColumnMapper
>
listFields
=
MapperMetadata
.
fieldsMap
.
get
(
entity
.
getClass
().
getSimpleName
());
SQL
sql
=
new
SQL
();
sql
.
UPDATE
(
MapperMetadata
.
getTableName
(
entity
.
getClass
()));
for
(
int
i
=
0
;
i
<
listFields
.
size
();
i
++)
{
FieldColumnMapper
fieldColumnMapper
=
listFields
.
get
(
i
);
if
(
fieldColumnMapper
.
isIdColumn
())
{
continue
;
}
if
(
fieldColumnMapper
.
getFieldType
().
equalsIgnoreCase
(
"String"
)&&
BeanUtil
.
getValue
(
entity
,
fieldColumnMapper
.
getFieldName
())==
null
)
{
//skip null field value
}
else
{
sql
.
SET
(
fieldColumnMapper
.
getColumnName
()
+
"=#{"
+
fieldColumnMapper
.
getFieldName
()
+
"}"
);
}
}
FieldColumnMapper
idFieldColumnMapper
=
MapperMetadata
.
getIdColumn
(
entity
.
getClass
().
getSimpleName
());
sql
.
WHERE
(
idFieldColumnMapper
.
getColumnName
()
+
"=#{"
+
idFieldColumnMapper
.
getFieldName
()+
"}"
);
_logger
.
trace
(
"Update SQL : \n"
+
sql
);
return
sql
.
toString
();
}
}
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/provider/package-info.java
0 → 100644
浏览文件 @
91c26db0
package
org.apache.mybatis.jpa.persistence.provider
;
\ No newline at end of file
mybatis-jpa-extra-core/src/test/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
浏览文件 @
91c26db0
...
...
@@ -27,6 +27,7 @@ public class MyBatisTestRunner {
public
void
insert
()
throws
Exception
{
_logger
.
info
(
"insert..."
);
Students
student
=
new
Students
();
//student.setId("10024");
student
.
setStdNo
(
"10024"
);
student
.
setStdGender
(
"M"
);
student
.
setStdName
(
"司马昭"
);
...
...
@@ -36,6 +37,7 @@ public class MyBatisTestRunner {
service
.
insert
(
student
);
Thread
.
sleep
(
1000
);
_logger
.
info
(
"insert id "
+
student
.
getId
());
service
.
remove
(
student
.
getId
());
}
...
...
mybatis-jpa-extra-spring-boot-starter-2.0.jar
已删除
100644 → 0
浏览文件 @
b60c2c63
文件已删除
mybatis-jpa-extra-spring-boot-starter-2.1.jar
0 → 100644
浏览文件 @
91c26db0
文件已添加
mybatis-jpa-extra-spring-boot-starter/pom.xml
浏览文件 @
91c26db0
...
...
@@ -6,7 +6,7 @@
<parent>
<groupId>
mybatis-jpa-extra
</groupId>
<artifactId>
mybatis-jpa-extra-parent
</artifactId>
<version>
2.0
</version>
<version>
${extra.version}
</version>
</parent>
<artifactId>
mybatis-jpa-extra-spring-boot-starter
</artifactId>
<name>
mybatis-jpa-extra-spring-boot-starter
</name>
...
...
@@ -19,18 +19,17 @@
</properties>
<dependencies>
<dependency>
<groupId>
mybatis-jpa-extra
</groupId>
<artifactId>
mybatis-jpa-extra
-2.1-api
</artifactId>
<version>
2.0
</version>
<artifactId>
mybatis-jpa-extra
</artifactId>
<version>
${extra.version}
</version>
</dependency>
<dependency>
<groupId>
mybatis-jpa-extra
</groupId>
<artifactId>
mybatis-jpa-extra
</artifactId>
<version>
2.0
</version>
<artifactId>
mybatis-jpa-extra
-test
</artifactId>
<version>
${extra.version}
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot
</artifactId>
<version>
${springboot.version}
</version>
...
...
mybatis-jpa-extra-
2.1-api
/.classpath
→
mybatis-jpa-extra-
test
/.classpath
浏览文件 @
91c26db0
<?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
including=
"**/*.java"
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"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.junit.JUNIT_CONTAINER/4"
/>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
</classpath>
<?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
including=
"**/*.java"
kind=
"src"
output=
"target/test-classes"
path=
"src/test/java"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"test"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
excluding=
"**"
kind=
"src"
output=
"target/test-classes"
path=
"src/test/resources"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"test"
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"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
</classpath>
mybatis-jpa-extra-
2.1-api
/.project
→
mybatis-jpa-extra-
test
/.project
浏览文件 @
91c26db0
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
mybatis-jpa-extra-
2.1-api
</name>
<name>
mybatis-jpa-extra-
test
</name>
<comment></comment>
<projects>
</projects>
...
...
@@ -10,11 +10,6 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.springframework.ide.eclipse.boot.validation.springbootbuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.m2e.core.maven2Builder
</name>
<arguments>
...
...
mybatis-jpa-extra-
2.1-api
/.settings/org.eclipse.core.resources.prefs
→
mybatis-jpa-extra-
test
/.settings/org.eclipse.core.resources.prefs
浏览文件 @
91c26db0
eclipse.preferences.version=1
encoding//src/main/java=utf8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
encoding//src/main/java=utf8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
mybatis-jpa-extra-
2.1-api
/.settings/org.eclipse.jdt.core.prefs
→
mybatis-jpa-extra-
test
/.settings/org.eclipse.jdt.core.prefs
浏览文件 @
91c26db0
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
mybatis-jpa-extra-
2.1-api
/.settings/org.eclipse.m2e.core.prefs
→
mybatis-jpa-extra-
test
/.settings/org.eclipse.m2e.core.prefs
浏览文件 @
91c26db0
文件已移动
mybatis-jpa-extra-
2.1-api
/pom.xml
→
mybatis-jpa-extra-
test
/pom.xml
浏览文件 @
91c26db0
<?xml version="1.0"?>
<project
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
>
<project
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
mybatis-jpa-extra
</groupId>
<artifactId>
mybatis-jpa-extra-parent
</artifactId>
<version>
2.0
</version>
<version>
${extra.version}
</version>
</parent>
<artifactId>
mybatis-jpa-extra-2.1-api
</artifactId>
<
name>
mybatis-jpa-extra-2.1-api
</name
>
<
description>
JPA 2.1 API Annotation
</description
>
<
artifactId>
mybatis-jpa-extra-test
</artifactId
>
<
name>
mybatis-jpa-extra-test
</name
>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
mybatis-jpa-extra
</groupId>
<artifactId>
mybatis-jpa-extra
</artifactId>
<version>
${extra.version}
</version>
</dependency>
</dependencies>
<build>
<testResources>
...
...
mybatis-jpa-extra-
spring-boot-starter/src/test
/java/org/apache/mybatis/jpa/test/dao/persistence/StudentsMapper.java
→
mybatis-jpa-extra-
test/src/main
/java/org/apache/mybatis/jpa/test/dao/persistence/StudentsMapper.java
浏览文件 @
91c26db0
文件已移动
mybatis-jpa-extra-
spring-boot-starter/src/test
/java/org/apache/mybatis/jpa/test/dao/service/StudentsService.java
→
mybatis-jpa-extra-
test/src/main
/java/org/apache/mybatis/jpa/test/dao/service/StudentsService.java
浏览文件 @
91c26db0
文件已移动
mybatis-jpa-extra-
spring-boot-starter/src/test
/java/org/apache/mybatis/jpa/test/domain/DemoDomain.java
→
mybatis-jpa-extra-
test/src/main
/java/org/apache/mybatis/jpa/test/domain/DemoDomain.java
浏览文件 @
91c26db0
文件已移动
mybatis-jpa-extra-
spring-boot-starter/src/test
/java/org/apache/mybatis/jpa/test/domain/Students.java
→
mybatis-jpa-extra-
test/src/main
/java/org/apache/mybatis/jpa/test/domain/Students.java
浏览文件 @
91c26db0
文件已移动
mybatis-jpa-extra-test/src/test/java/org/apache/mybatis/jpa/test/ApplicationRunner.properties
0 → 100644
浏览文件 @
91c26db0
mybatis-jpa-extra-test/src/test/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
0 → 100644
浏览文件 @
91c26db0
package
org.apache.mybatis.jpa.test
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.mybatis.jpa.test.dao.service.StudentsService
;
import
org.apache.mybatis.jpa.test.domain.Students
;
import
org.apache.mybatis.jpa.util.WebContext
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
public
class
MyBatisTestRunner
{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
MyBatisTestRunner
.
class
);
public
static
ApplicationContext
context
;
public
static
StudentsService
service
;
@Test
public
void
insert
()
throws
Exception
{
_logger
.
info
(
"insert..."
);
Students
student
=
new
Students
();
//student.setId("10024");
student
.
setStdNo
(
"10024"
);
student
.
setStdGender
(
"M"
);
student
.
setStdName
(
"司马昭"
);
student
.
setStdAge
(
20
);
student
.
setStdMajor
(
"政治"
);
student
.
setStdClass
(
"4"
);
service
.
insert
(
student
);
Thread
.
sleep
(
1000
);
_logger
.
info
(
"insert id "
+
student
.
getId
());
service
.
remove
(
student
.
getId
());
}
@Test
public
void
get
()
throws
Exception
{
_logger
.
info
(
"get..."
);
Students
student
=
service
.
get
(
"921d3377-937a-4578-b1e2-92fb23b5e512"
);
System
.
out
.
println
(
"Students "
+
student
);
_logger
.
info
(
"Students "
+
student
);
}
@Test
public
void
remove
()
throws
Exception
{
_logger
.
info
(
"remove..."
);
Students
student
=
new
Students
();
student
.
setId
(
"921d3377-937a-4578-b1e2-92fb23b5e512"
);
service
.
remove
(
student
.
getId
());
}
@Test
public
void
batchDelete
()
throws
Exception
{
_logger
.
info
(
"batchDelete..."
);
List
<
String
>
idList
=
new
ArrayList
<
String
>();
idList
.
add
(
"8584804d-b5ac-45d2-9f91-4dd8e7a090a7"
);
idList
.
add
(
"ab7422e9-a91a-4840-9e59-9d911257c918"
);
idList
.
add
(
"12b6ceb8-573b-4f01-ad85-cfb24cfa007c"
);
idList
.
add
(
"dafd5ba4-d2e3-4656-bd42-178841e610fe"
);
service
.
batchDelete
(
idList
);
}
@Test
public
void
queryPageResults
()
throws
Exception
{
_logger
.
info
(
"queryPageResults..."
);
Students
student
=
new
Students
();
//student.setId("af04d610-6092-481e-9558-30bd63ef783c");
student
.
setStdGender
(
"M"
);
//student.setStdMajor(政治");
student
.
setPageSize
(
10
);
student
.
setPageNumber
(
2
);
List
<
Students
>
allListStudents
=
service
.
queryPageResults
(
student
).
getRows
();
for
(
Students
s
:
allListStudents
)
{
_logger
.
info
(
"Students "
+
s
);
}
}
@Test
public
void
queryPageResultsByMapperId
()
throws
Exception
{
_logger
.
info
(
"queryPageResults by mapperId..."
);
Students
student
=
new
Students
();
student
.
setStdGender
(
"M"
);
//student.setStdMajor(政治");
student
.
setPageSize
(
10
);
student
.
setPageNumber
(
2
);
List
<
Students
>
allListStudents
=
service
.
queryPageResults
(
"queryPageResults1"
,
student
).
getRows
();
for
(
Students
s
:
allListStudents
)
{
_logger
.
info
(
"Students "
+
s
);
}
}
@Test
public
void
findAll
()
throws
Exception
{
_logger
.
info
(
"findAll..."
);
List
<
Students
>
allListStudents
=
service
.
findAll
();
for
(
Students
s
:
allListStudents
)
{
_logger
.
info
(
"Students "
+
s
);
}
}
@Before
public
void
initSpringContext
(){
if
(
context
!=
null
)
return
;
_logger
.
info
(
"init Spring Context..."
);
SimpleDateFormat
sdf_ymdhms
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
startTime
=
sdf_ymdhms
.
format
(
new
Date
());
try
{
MyBatisTestRunner
runner
=
new
MyBatisTestRunner
();
runner
.
init
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
_logger
.
info
(
"-- --Init Start at "
+
startTime
+
" , End at "
+
sdf_ymdhms
.
format
(
new
Date
()));
}
//Initialization ApplicationContext for Project
public
void
init
(){
_logger
.
info
(
"Application dir "
+
System
.
getProperty
(
"user.dir"
));
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]
{
"spring/applicationContext.xml"
});
WebContext
.
applicationContext
=
context
;
service
=(
StudentsService
)
WebContext
.
getBean
(
"studentsService"
);
}
}
mybatis-jpa-extra-test/src/test/java/org/apache/mybatis/jpa/test/SerialGeneratorTest.java
0 → 100644
浏览文件 @
91c26db0
package
org.apache.mybatis.jpa.test
;
import
org.apache.mybatis.jpa.id.SerialGenerator
;
import
org.apache.mybatis.jpa.util.MacAddress
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
SerialGeneratorTest
{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
SerialGeneratorTest
.
class
);
@Test
public
void
generator
()
{
// TODO Auto-generated method stub
SerialGenerator
serialGenerator
=
new
SerialGenerator
();
_logger
.
info
(
serialGenerator
.
generate
(
""
));
_logger
.
info
(
MacAddress
.
getAllHostMacAddress
());
}
}
mybatis-jpa-extra-test/src/test/java/org/apache/mybatis/jpa/test/UUIDHexGeneratorTest.java
0 → 100644
浏览文件 @
91c26db0
package
org.apache.mybatis.jpa.test
;
import
org.apache.mybatis.jpa.id.UUIDHexGenerator
;
import
org.junit.Test
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
UUIDHexGeneratorTest
{
private
static
final
Logger
_logger
=
LoggerFactory
.
getLogger
(
UUIDHexGeneratorTest
.
class
);
@Test
public
void
generator
()
{
// TODO Auto-generated method stub
UUIDHexGenerator
uhg
=
new
UUIDHexGenerator
();
_logger
.
info
(
uhg
.
generate
(
""
));
_logger
.
info
(
uhg
.
generate
(
""
));
}
}
mybatis-jpa-extra-test/src/test/resources/config/applicationConfig.properties
0 → 100644
浏览文件 @
91c26db0
############################################################################
# DataBase configuration
############################################################################
#db2,derby,mysql,oracle,postgresql,sqlserver
config.datasource.database
=
mysql
# JDBC Driver
# for MySql com.mysql.jdbc.Driver
# for oracle oracle.jdbc.driver.OracleDriver
# for DB2 com.ibm.db2.jdbc.app.DB2Driver
# com.ibm.db2.jcc.DB2Driver
# for SqlServer com.microsoft.jdbc.sqlserver.SQLServerDriver
# for SyBase com.sybase.jdbc.SybDriver
# for PostgreSQL org.postgresql.Driver
# for Derby org.apache.derby.jdbc.ClientDriver
# JDBC URL
# you need database hostname,port,databasename
# for MySql jdbc:mysql://hostname:port/secdb
# for oracle jdbc:oracle:thin:@hostname:port:secdb
# for DB2 jdbc:db2://hostname:port/secdb
# for SqlServer jdbc:microsoft:sqlserver://hostname:port;DatabaseName=secdb
# for SyBase jdbc:sybase:Tds:hostname:port/secdb
# for Derby jdbc:derby://localhost:1527/secdb
#
config.datasource.driverclass
=
com.mysql.jdbc.Driver
config.datasource.url
=
jdbc:mysql://localhost/test?autoReconnect=true&characterEncoding=UTF-8
config.datasource.username
=
root
config.datasource.password
=
maxkey
############################################################################
\ No newline at end of file
mybatis-jpa-extra-test/src/test/resources/log4j2.xml
0 → 100644
浏览文件 @
91c26db0
<?xml version="1.0" encoding="UTF-8"?>
<configuration
status=
"DEBUG"
>
<appenders>
<Console
name=
"consolePrint"
target=
"SYSTEM_OUT"
>
<PatternLayout
pattern=
"%d{YYYY-MM-dd HH:mm:ss,SSS} [%t] %-5level %logger{36} - %msg%n"
/>
</Console>
</appenders>
<loggers>
<root
level=
"debug"
>
<appender-ref
ref=
"consolePrint"
/>
</root>
<Logger
name=
"org.springframework"
level=
"INFO"
>
<appender-ref
ref=
"consolePrint"
/>
</Logger>
<Logger
name=
"org.apache.mybatis"
level=
"DEBUG"
>
<appender-ref
ref=
"consolePrint"
/>
</Logger>
</loggers>
</configuration>
\ No newline at end of file
mybatis-jpa-extra-test/src/test/resources/org/apache/mybatis/jpa/test/dao/persistence/xml/mysql/StudentsMapper.xml
0 → 100644
浏览文件 @
91c26db0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"org.apache.mybatis.jpa.test.dao.persistence.StudentsMapper"
>
<sql
id=
"sql_condition"
>
WHERE 1 = 1
<if
test=
"id != null"
>
AND ID = '${id}'
</if>
<if
test=
"stdName != null and stdName != '' "
>
AND STDNAME like '%${stdName}%'
</if>
<if
test=
"stdGender != null and stdGender != '' "
>
AND STDGENDER = #{stdGender}
</if>
<if
test=
"stdMajor != null"
>
<![CDATA[AND STDMAJOR = #{stdMajor}]]>
</if>
</sql>
<select
id=
"queryPageResults"
parameterType=
"Students"
resultType=
"Students"
>
SELECT
ID ,
STDNO ,
STDNAME ,
STDGENDER ,
STDAGE ,
STDMAJOR ,
STDCLASS
FROM STUDENTS
<include
refid=
"sql_condition"
/>
</select>
<select
id=
"queryPageResults1"
parameterType=
"Students"
resultType=
"Students"
>
SELECT
ID ,
STDNO ,
STDNAME ,
STDGENDER ,
STDAGE ,
STDMAJOR ,
STDCLASS
FROM STUDENTS
<include
refid=
"sql_condition"
/>
AND STDGENDER IN (
SELECT STDGENDER FROM STUDENTS
)
</select>
<select
id=
"queryBy"
parameterType=
"Students"
resultType=
"Students"
>
SELECT
ID ,
STDNO ,
STDNAME ,
STDGENDER ,
STDAGE ,
STDMAJOR ,
STDCLASS
FROM ROLES
<include
refid=
"sql_condition"
/>
</select>
<delete
id=
"delete"
parameterType=
"Students"
>
DELETE FROM STUDENTS WHERE ID=#{id}
</delete>
</mapper>
\ No newline at end of file
mybatis-jpa-extra-test/src/test/resources/org/apache/mybatis/jpa/test/dao/persistence/xml/oracle/StudentsMapper1.xml
0 → 100644
浏览文件 @
91c26db0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"org.apache.mybatis.jpa.test.dao.persistence.StudentsMapper"
>
<sql
id=
"sql_condition"
>
WHERE 1 = 1
<if
test=
"id != null"
>
AND ID = '${id}'
</if>
<if
test=
"stdName != null and stdName != '' "
>
AND STDNAME like '%${stdName}%'
</if>
<if
test=
"stdGender != null and stdGender != '' "
>
AND STDGENDER = #{stdGender}
</if>
<if
test=
"stdMajor != null"
>
<![CDATA[AND STDMAJOR = #{stdMajor}]]>
</if>
</sql>
<select
id=
"queryPageResults"
parameterType=
"Students"
resultType=
"Students"
>
SELECT
ID ,
STDNO ,
STDNAME ,
STDGENDER ,
STDAGE ,
STDMAJOR ,
STDCLASS
FROM STUDENTS
<include
refid=
"sql_condition"
/>
</select>
<select
id=
"queryPageResults1"
parameterType=
"Students"
resultType=
"Students"
>
SELECT
ID ,
STDNO ,
STDNAME ,
STDGENDER ,
STDAGE ,
STDMAJOR ,
STDCLASS
FROM STUDENTS
<include
refid=
"sql_condition"
/>
</select>
<select
id=
"query"
parameterType=
"Students"
resultType=
"Students"
>
SELECT
ID ,
STDNO ,
STDNAME ,
STDGENDER ,
STDAGE ,
STDMAJOR ,
STDCLASS
FROM ROLES
<include
refid=
"sql_condition"
/>
</select>
<delete
id=
"delete"
parameterType=
"Students"
>
DELETE FROM STUDENTS WHERE ID=#{id}
</delete>
</mapper>
\ No newline at end of file
mybatis-jpa-extra-test/src/test/resources/spring/applicationContext-database.xml
0 → 100644
浏览文件 @
91c26db0
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop=
"http://www.springframework.org/schema/aop"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xmlns:jdbc=
"http://www.springframework.org/schema/jdbc"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd"
>
<!-- dataSource define begin -->
<!-- c3p0 configuration
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" >
<property name="driverClass" value="${config.datasource.driverclass}"/>
<property name="jdbcUrl" value="${config.datasource.url}"/>
<property name="user" value="${config.datasource.username}"/>
<property name="password" value="${config.datasource.password}"/>
<property name="maxPoolSize" value="30"/>
<property name="minPoolSize" value="21"/>
<property name="initialPoolSize" value="15"/>
</bean>
-->
<bean
id=
"dataSource"
class=
"com.alibaba.druid.pool.DruidDataSource"
destroy-method=
"close"
>
<!-- <property name="driverClass" value="#{dataSoruceConfig.driverClass}"/> -->
<property
name=
"url"
value=
"${config.datasource.url}"
/>
<property
name=
"username"
value=
"${config.datasource.username}"
/>
<property
name=
"password"
value=
"${config.datasource.password}"
/>
</bean>
</beans>
\ No newline at end of file
mybatis-jpa-extra-test/src/test/resources/spring/applicationContext-persist.xml
0 → 100644
浏览文件 @
91c26db0
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:p=
"http://www.springframework.org/schema/p"
xmlns:aop=
"http://www.springframework.org/schema/aop"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xmlns:cache=
"http://www.springframework.org/schema/cache"
xsi:schemaLocation=
"
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-3.2.xsd"
>
<bean
id=
"jdbcTemplate"
class=
"org.springframework.jdbc.core.JdbcTemplate"
>
<property
name=
"dataSource"
ref=
"dataSource"
/>
</bean>
<tx:annotation-driven
transaction-manager=
"txManager"
/>
<bean
id=
"txManager"
class=
"org.springframework.jdbc.datasource.DataSourceTransactionManager"
>
<property
name=
"dataSource"
ref=
"dataSource"
/>
</bean>
<!-- enable autowire
<context:annotation-config />-->
<!-- enable transaction demarcation with annotations
<tx:annotation-driven />-->
<!--<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">-->
<bean
id=
"sqlSessionFactory"
class=
"org.apache.mybatis.jpa.MyBatisSessionFactoryBean"
>
<property
name=
"timeout"
value=
"30"
/>
<property
name=
"dialect"
value=
"mysql"
/>
<property
name=
"dataSource"
ref=
"dataSource"
/>
<property
name=
"mapperLocations"
value=
"classpath*:/org/apache/mybatis/jpa/test/dao/persistence/xml/mysql/*.xml"
/>
<property
name=
"typeAliasesPackage"
value=
"
org.apache.mybatis.jpa.test.domain,
"
/>
<property
name=
"transactionFactory"
>
<bean
class=
"org.apache.ibatis.transaction.managed.ManagedTransactionFactory"
/>
</property>
</bean>
<!-- scan for mappers and let them be autowired -->
<bean
class=
"org.mybatis.spring.mapper.MapperScannerConfigurer"
>
<property
name=
"basePackage"
value=
"
org.apache.mybatis.jpa.test.dao.persistence,
"
/>
</bean>
<!-- enable component scanning (beware that this does not enable mapper scanning!) -->
<context:component-scan
base-package=
"org.apache.mybatis.jpa.test.dao.service"
/>
<bean
class =
"org.apache.mybatis.jpa.id.IdentifierGeneratorFactory"
>
<property
name=
"generatorStrategyMap"
>
<map>
<entry
key=
"serial"
>
<bean
class=
"org.apache.mybatis.jpa.id.SerialGenerator"
>
<property
name=
"ipAddressNodeValue"
value=
"F0-76-1C-B0-26-9C=02,"
/>
</bean></entry>
</map>
</property>
</bean>
<!--
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
-->
</beans>
\ No newline at end of file
mybatis-jpa-extra-test/src/test/resources/spring/applicationContext.xml
0 → 100644
浏览文件 @
91c26db0
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:mvc=
"http://www.springframework.org/schema/mvc"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:p=
"http://www.springframework.org/schema/p"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xmlns:util=
"http://www.springframework.org/schema/util"
xsi:schemaLocation=
"
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"
>
<!--
<import resource="applicationContext-task.xml"/>
-->
<!-- Application properties configs -->
<bean
id=
"propertySourcesPlaceholderConfigurer"
class=
"org.springframework.context.support.PropertySourcesPlaceholderConfigurer"
>
<property
name=
"locations"
>
<list>
<value>
classpath:config/applicationConfig.properties
</value>
</list>
</property>
<property
name=
"ignoreUnresolvablePlaceholders"
value=
"true"
/>
</bean>
<!-- Datastore configuration -->
<import
resource=
"applicationContext-database.xml"
/>
<import
resource=
"applicationContext-persist.xml"
/>
<!-- 配置执行的任务列表 -->
<util:list
id=
"businessTask"
list-class=
"java.util.ArrayList"
>
</util:list>
</beans>
\ No newline at end of file
mybatis-jpa-extra-test/src/test/resources/students-mysql.sql
0 → 100644
浏览文件 @
91c26db0
CREATE
TABLE
STUDENTS
(
STDNO
VARCHAR
(
100
),
STDNAME
VARCHAR
(
100
),
STDGENDER
VARCHAR
(
100
),
STDAGE
int
,
STDMAJOR
VARCHAR
(
100
),
STDCLASS
VARCHAR
(
100
),
ID
VARCHAR
(
100
)
)
ENGINE
=
InnoDB
DEFAULT
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
;
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10001'
,
'刘备'
,
'M'
,
40
,
'政治'
,
'1'
,
'8c34448b-c65b-4a4e-a0da-83284d05f909'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10002'
,
'关羽'
,
'M'
,
37
,
'物理'
,
'1'
,
'b9111f83-d338-461d-8d46-f331087d5a42'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10003'
,
'张飞'
,
'M'
,
38
,
'政治'
,
'1'
,
'1297510b-5f47-4425-b1cf-778425254142'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10004'
,
'赵云'
,
'M'
,
29
,
'历史'
,
'1'
,
'940908e2-7c58-429a-bcef-8b566befed00'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10005'
,
'黄忠'
,
'M'
,
68
,
'化学'
,
'1'
,
'05084723-77a8-425a-870e-e33d00e53fd2'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10006'
,
'魏延'
,
'M'
,
35
,
'化学'
,
'1'
,
'37e4b3b4-3c76-4bf3-8165-f514d14ff54f'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10007'
,
'马超'
,
'M'
,
29
,
'历史'
,
'1'
,
'f8d34aac-93d6-47ab-915e-fcd169007f62'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10008'
,
'姜维'
,
'M'
,
20
,
'政治'
,
'1'
,
'd252f326-c0ac-46cb-82fc-cb2597edaf41'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10009'
,
'孙策'
,
'M'
,
43
,
'政治'
,
'2'
,
'e4b748e6-ff3c-4727-9fc2-458b97cb318d'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10010'
,
'周瑜'
,
'M'
,
39
,
'数学'
,
'2'
,
'c38f8afd-a6bc-458d-9f9a-fb22f30c7e39'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10011'
,
'鲁肃'
,
'M'
,
34
,
'物理'
,
'2'
,
'71aaa4dd-9720-4f76-a825-357842de3c88'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10012'
,
'吕蒙'
,
'M'
,
20
,
'数学'
,
'2'
,
'dba0b7b9-97bf-41ac-8ac1-652b1fa05c9a'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10013'
,
'孙权'
,
'M'
,
20
,
'政治'
,
'2'
,
'3f1e0276-8104-44a0-9231-2759777b08ee'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10014'
,
'陆逊'
,
'M'
,
18
,
'数学'
,
'2'
,
'2120f7a5-00d9-44ff-92ee-ae1e2bc212e2'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10015'
,
'曹操'
,
'M'
,
46
,
'政治'
,
'3'
,
'715c53ac-c85d-4049-9ef9-abf4e3d91d15'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10016'
,
'典韦'
,
'M'
,
28
,
'历史'
,
'3'
,
'293745a9-c33e-47d2-9844-8668574d3b60'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10017'
,
'曹仁'
,
'M'
,
40
,
'数学'
,
'3'
,
'f29ca87a-7b85-4ed6-b57b-8ab75128487b'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10018'
,
'司马懿'
,
'M'
,
38
,
'政治'
,
'3'
,
'8793f911-fc0a-49fa-9ca7-2ab4e6a19454'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10019'
,
'邓艾'
,
'M'
,
17
,
'军事'
,
'3'
,
'317d5eda-927c-4871-a916-472a8062df23'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10020'
,
'大乔'
,
'F'
,
25
,
'艺术'
,
'4'
,
'3edd3ce2-1b13-46c9-8f39-37522052f2cc'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10021'
,
'小乔'
,
'F'
,
23
,
'艺术'
,
'4'
,
'd353a108-657d-47c3-8aef-e6936fd9a58e'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10022'
,
'孙尚香'
,
'F'
,
26
,
'历史'
,
'4'
,
'22f2914c-37bc-4e05-b0da-3d02f682008a'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10023'
,
'貂蝉'
,
'F'
,
20
,
'艺术'
,
'4'
,
'af04d610-6092-481e-9558-30bd63ef783c'
);
mybatis-jpa-extra-test/src/test/resources/students-oracle.sql
0 → 100644
浏览文件 @
91c26db0
CREATE
TABLE
STUDENTS
(
STDNO
VARCHAR2
(
100
),
STDNAME
VARCHAR2
(
100
),
STDGENDER
VARCHAR2
(
100
),
STDAGE
NUMBER
,
STDMAJOR
VARCHAR2
(
100
),
STDCLASS
VARCHAR2
(
100
),
ID
VARCHAR2
(
100
)
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10001'
,
'刘备'
,
'M'
,
40
,
'政治'
,
'1'
,
'8c34448b-c65b-4a4e-a0da-83284d05f909'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10002'
,
'关羽'
,
'M'
,
37
,
'物理'
,
'1'
,
'b9111f83-d338-461d-8d46-f331087d5a42'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10003'
,
'张飞'
,
'M'
,
38
,
'政治'
,
'1'
,
'1297510b-5f47-4425-b1cf-778425254142'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10004'
,
'赵云'
,
'M'
,
29
,
'历史'
,
'1'
,
'940908e2-7c58-429a-bcef-8b566befed00'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10005'
,
'黄忠'
,
'M'
,
68
,
'化学'
,
'1'
,
'05084723-77a8-425a-870e-e33d00e53fd2'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10006'
,
'魏延'
,
'M'
,
35
,
'化学'
,
'1'
,
'37e4b3b4-3c76-4bf3-8165-f514d14ff54f'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10007'
,
'马超'
,
'M'
,
29
,
'历史'
,
'1'
,
'f8d34aac-93d6-47ab-915e-fcd169007f62'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10008'
,
'姜维'
,
'M'
,
20
,
'政治'
,
'1'
,
'd252f326-c0ac-46cb-82fc-cb2597edaf41'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10009'
,
'孙策'
,
'M'
,
43
,
'政治'
,
'2'
,
'e4b748e6-ff3c-4727-9fc2-458b97cb318d'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10010'
,
'周瑜'
,
'M'
,
39
,
'数学'
,
'2'
,
'c38f8afd-a6bc-458d-9f9a-fb22f30c7e39'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10011'
,
'鲁肃'
,
'M'
,
34
,
'物理'
,
'2'
,
'71aaa4dd-9720-4f76-a825-357842de3c88'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10012'
,
'吕蒙'
,
'M'
,
20
,
'数学'
,
'2'
,
'dba0b7b9-97bf-41ac-8ac1-652b1fa05c9a'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10013'
,
'孙权'
,
'M'
,
20
,
'政治'
,
'2'
,
'3f1e0276-8104-44a0-9231-2759777b08ee'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10014'
,
'陆逊'
,
'M'
,
18
,
'数学'
,
'2'
,
'2120f7a5-00d9-44ff-92ee-ae1e2bc212e2'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10015'
,
'曹操'
,
'M'
,
46
,
'政治'
,
'3'
,
'715c53ac-c85d-4049-9ef9-abf4e3d91d15'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10016'
,
'典韦'
,
'M'
,
28
,
'历史'
,
'3'
,
'293745a9-c33e-47d2-9844-8668574d3b60'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10017'
,
'曹仁'
,
'M'
,
40
,
'数学'
,
'3'
,
'f29ca87a-7b85-4ed6-b57b-8ab75128487b'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10018'
,
'司马懿'
,
'M'
,
38
,
'政治'
,
'3'
,
'8793f911-fc0a-49fa-9ca7-2ab4e6a19454'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10019'
,
'邓艾'
,
'M'
,
17
,
'军事'
,
'3'
,
'317d5eda-927c-4871-a916-472a8062df23'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10020'
,
'大乔'
,
'F'
,
25
,
'艺术'
,
'4'
,
'3edd3ce2-1b13-46c9-8f39-37522052f2cc'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10021'
,
'小乔'
,
'F'
,
23
,
'艺术'
,
'4'
,
'd353a108-657d-47c3-8aef-e6936fd9a58e'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10022'
,
'孙尚香'
,
'F'
,
26
,
'历史'
,
'4'
,
'22f2914c-37bc-4e05-b0da-3d02f682008a'
);
insert
into
STUDENTS
(
STDNO
,
STDNAME
,
STDGENDER
,
STDAGE
,
STDMAJOR
,
STDCLASS
,
ID
)
values
(
'10023'
,
'貂蝉'
,
'F'
,
20
,
'艺术'
,
'4'
,
'af04d610-6092-481e-9558-30bd63ef783c'
);
pom.xml
浏览文件 @
91c26db0
...
...
@@ -3,12 +3,12 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
mybatis-jpa-extra
</groupId>
<artifactId>
mybatis-jpa-extra-parent
</artifactId>
<version>
2.0
</version>
<version>
${extra.version}
</version>
<packaging>
pom
</packaging>
<modules>
<module>
mybatis-jpa-extra-2.1-api
</module>
<module>
mybatis-jpa-extra-core
</module>
<module>
mybatis-jpa-extra-spring-boot-starter
</module>
<module>
mybatis-jpa-extra-test
</module>
</modules>
<properties>
...
...
@@ -28,6 +28,9 @@
<jackson.version1>
1.9.13
</jackson.version1>
<jackson.version2>
2.10.0
</jackson.version2>
<druid.version>
1.1.22
</druid.version>
<persistence.version>
2.2.1
</persistence.version>
<extra.version>
2.1
</extra.version>
</properties>
<repositories>
...
...
@@ -163,6 +166,12 @@
<artifactId>
commons-lang
</artifactId>
<version>
2.5
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.persistence/javax.persistence -->
<dependency>
<groupId>
org.eclipse.persistence
</groupId>
<artifactId>
javax.persistence
</artifactId>
<version>
${persistence.version}
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录