Skip to content

Commit 68185e8

Browse files
author
mhyeon-lee
committed
Squash All for open source
1 parent b6e987e commit 68185e8

File tree

178 files changed

+19450
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+19450
-1
lines changed

.editorconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
[*.{kt, kts}]
5+
disabled_rules = import-ordering
6+
7+
[*]
8+
# [encoding-utf8]
9+
charset = utf-8
10+
11+
# [newline-lf]
12+
end_of_line = lf
13+
14+
# [newline-eof]
15+
insert_final_newline = true
16+
17+
[*.bat]
18+
end_of_line = crlf
19+
20+
[*.java]
21+
# [indentation-tab]
22+
indent_style = tab
23+
24+
# [4-spaces-tab]
25+
indent_size = 4
26+
tab_width = 4
27+
28+
# [no-trailing-spaces]
29+
trim_trailing_whitespace = true
30+
31+
[line-length-120]
32+
max_line_length = 120

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.gradle
2+
build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
/bin/
5+
/env.bat
6+
7+
generated
8+
9+
### STS ###
10+
.apt_generated
11+
.classpath
12+
.factorypath
13+
.project
14+
.settings
15+
.springBeans
16+
.sts4-cache
17+
18+
### IntelliJ IDEA ###
19+
.idea
20+
*.iws
21+
*.iml
22+
*.ipr
23+
out/
24+
25+
### Mac OS ###
26+
.DS_Store

README.md

Lines changed: 178 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,181 @@
1-
# Spring JDBC Plus
1+
# Spring JDBC Plus [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/naver/spring-jdbc-plus)
2+
Spring JDBC SQL provides [Spring Data JDBC](https://github.com/spring-projects/spring-data-jdbc) based extension.
3+
It provides necessary features when writing more complex SQL than the functions supported by `CrudRepository`.
4+
If you need to use Spring Data JDBC's Persistence features and SQL execution function in combination, `Spring JDBC Plus` may be an appropriate choice.
5+
6+
## Features
7+
- Support for executing custom `SQL SELECT` statements
8+
- Provide `BeanParameterSource`, `MapParameterSource`, `EntityParameterSource`
9+
- Provide parameter source converters such as `Java8Time`,`Enum`, etc.
10+
- Entity mapping support for complex table join SELECT results
11+
- `AggregateResultSet` supports mapping of `1: N` result data to `Aggregate` object graph by `LEFT OUTER JOIN` lookup
12+
- `JdbcRepository` provides insert / update syntax
13+
- Support for setting `Reactive (Flux / Mono)` type as the return type of `CustomRepository` method
14+
15+
- [User Guide](https://github.com/naver/spring-jdbc-plus/wiki)
16+
17+
## Getting Started (Spring Boot Starter Data JDBC Plus SQL)
18+
* Gradle
19+
```gradle
20+
buildscript {
21+
repositories {
22+
mavenCentral()
23+
mavenLocal()
24+
maven {
25+
url "https://repo.spring.io/milestone/"
26+
}
27+
}
28+
dependencies {
29+
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.6.RELEASE")
30+
}
31+
}
32+
33+
dependencies {
34+
implementation("com.navercorp.spring:spring-boot-starter-data-jdbc-plus-sql:2.0.0.RC2")
35+
implementation("org.springframework.data:spring-data-jdbc:2.0.0.RC2")
36+
implementation("org.springframework.data:spring-data-relational:2.0.0.RC2")
37+
implementation("org.springframework.data:spring-data-commons:2.3.0.RC2")
38+
}
39+
```
40+
41+
* Maven
42+
```xml
43+
<repositories>
44+
<repository>
45+
<id>repository.spring.milestone</id>
46+
<name>Spring Milestone Repository</name>
47+
<url>http://repo.spring.io/milestone</url>
48+
</repository>
49+
</repositories>
50+
51+
<dependency>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>com.navercorp.spring:spring-boot-starter-data-jdbc-plus-sql</artifactId>
54+
<version>2.0.0.RC2</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.springframework.data</groupId>
58+
<artifactId>spring-data-jdbc</artifactId>
59+
<version>2.0.0.RC2</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.springframework.data</groupId>
63+
<artifactId>spring-data-relational</artifactId>
64+
<version>2.0.0.RC2</version>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.springframework.data</groupId>
68+
<artifactId>spring-data-commons</artifactId>
69+
<version>2.3.0.RC2</version>
70+
</dependency>
71+
```
72+
73+
* Java Codes
74+
75+
```java
76+
@Table("n_order")
77+
@Data
78+
public class Order {
79+
@Id
80+
@Column("order_no")
81+
private Long orderNo;
82+
83+
@Column("price")
84+
private long price;
85+
86+
@Column("purchaser_no")
87+
private String purchaserNo;
88+
}
89+
90+
public interface OrderRepository extends CrudRepository<Order, Long>, OrderRepositoryCustom {
91+
}
92+
93+
public interface OrderRepositoryCustom {
94+
List<Order> findByPurchaserNo(String purchaserNo);
95+
}
96+
97+
public class OrderRepositoryImpl extends JdbcRepositorySupport<Order> implements OrderRepositoryCustom {
98+
private final OrderSql sqls;
99+
100+
public OrderRepositoryImpl(EntityJdbcProvider entityJdbcProvider) {
101+
super(Order.class, entityJdbcProvider);
102+
this.sql = sqls(OrderSql::new);
103+
}
104+
105+
@Override
106+
public List<Order> findByPurchaserNo(String purchaserNo) {
107+
String sql = this.sql.selectByPurchaserNo();
108+
return find(sql, mapParameterSource()
109+
.addValue("purchaserNo", purchaserNo));
110+
}
111+
}
112+
```
113+
114+
* Groovy codes for SQL
115+
```groovy
116+
class OrderSql extends SqlGeneratorSupport {
117+
118+
String selectByPurchaserNo() {
119+
"""
120+
SELECT ${sql.columns(Order)}
121+
FROM n_order
122+
WHERE purchaser_no = :purchaserNo
123+
"""
124+
}
125+
}
126+
```
127+
128+
* Cautions when writing SQL
129+
- It is recommended to use NamedParameter for the parameter to be bound to SQL.
130+
- SQL Injection vulnerability, Prepared Statement Cache, etc. are affected.
131+
132+
* Bad :-1:
133+
```groovy
134+
class OrderSql extends SqlGeneratorSupport {
135+
136+
String selectByPurchaserNo(String purchaserNo) {
137+
"""
138+
SELECT ${sql.columns(Order)}
139+
FROM n_order
140+
WHERE purchaser_no = '${purchaserNo}'
141+
"""
142+
}
143+
}
144+
```
145+
146+
* Good :+1:
147+
```groovy
148+
class OrderSql extends SqlGeneratorSupport {
149+
150+
String selectByPurchaserNo() {
151+
"""
152+
SELECT ${sql.columns(Order)}
153+
FROM n_order
154+
WHERE purchaser_no = :purchaserNo
155+
"""
156+
}
157+
}
158+
```
159+
160+
## Examples
161+
* [Java + Groovy SQL Example](./guide-projects/plus-sql-java-groovy-guide)
162+
* [Java + Kotlin SQL Example](./guide-projects/plus-sql-java-kotlin-guide)
163+
* [Kotlin Example](./guide-projects/plus-sql-kotlin-guide)
164+
165+
## Getting Help
166+
- [User Guide](https://github.com/naver/spring-jdbc-plus/wiki)
167+
- [Reporting Issues](https://github.com/naver/spring-jdbc-plus/issues)
168+
169+
## Coding Convention
170+
- [naver hackday-conventions-java](https://naver.github.io/hackday-conventions-java/)
171+
- https://github.com/naver/hackday-conventions-java)
172+
- checkstyle: ./rule/naver-checkstyle-rules.xml
173+
- intellij-formatter: ./rule/naver-intellij-formatter.xml (https://naver.github.io/hackday-conventions-java/#editor-config)
174+
175+
## Building from Source
176+
```
177+
$ ./gradlew clean build
178+
```
2179

3180
## License
4181

build.gradle

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import org.springframework.boot.gradle.plugin.SpringBootPlugin
2+
3+
buildscript {
4+
repositories {
5+
mavenCentral()
6+
mavenLocal()
7+
maven {
8+
url "https://repo.spring.io/milestone/"
9+
}
10+
}
11+
dependencies {
12+
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.6.RELEASE")
13+
}
14+
}
15+
16+
allprojects {
17+
group = "com.navercorp.spring"
18+
version = "2.0.0.RC2"
19+
}
20+
21+
subprojects {
22+
apply plugin: "java"
23+
apply plugin: "idea"
24+
apply plugin: "checkstyle"
25+
apply plugin: "io.spring.dependency-management"
26+
apply plugin: "maven"
27+
apply plugin: "signing"
28+
29+
sourceCompatibility = JavaVersion.VERSION_1_8
30+
targetCompatibility = JavaVersion.VERSION_1_8
31+
32+
repositories {
33+
mavenCentral()
34+
maven {
35+
url "https://repo.spring.io/milestone/"
36+
}
37+
}
38+
39+
dependencies {
40+
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
41+
testCompileOnly("com.google.code.findbugs:jsr305:3.0.2")
42+
}
43+
44+
dependencyManagement {
45+
imports {
46+
mavenBom SpringBootPlugin.BOM_COORDINATES
47+
}
48+
}
49+
50+
checkstyle {
51+
configFile = file("${project.rootDir}/rule/naver-checkstyle-rules.xml")
52+
configProperties = [config_loc: ".."]
53+
toolVersion = "8.24"
54+
}
55+
56+
test {
57+
useJUnitPlatform()
58+
}
59+
60+
task javadocJar(type: Jar) {
61+
archiveClassifier = 'javadoc'
62+
from javadoc
63+
}
64+
65+
task sourcesJar(type: Jar) {
66+
archiveClassifier = 'sources'
67+
from sourceSets.main.allSource
68+
}
69+
70+
artifacts {
71+
archives javadocJar, sourcesJar
72+
}
73+
74+
signing {
75+
sign configurations.archives
76+
}
77+
78+
uploadArchives {
79+
repositories {
80+
mavenDeployer {
81+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
82+
83+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
84+
authentication(userName: ossrhUsername, password: ossrhPassword)
85+
}
86+
87+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
88+
authentication(userName: ossrhUsername, password: ossrhPassword)
89+
}
90+
91+
pom.project {
92+
name project.name
93+
packaging "jar"
94+
description "Spring JDBC Plus"
95+
url "https://github.com/naver/spring-jdbc-plus"
96+
97+
scm {
98+
connection "scm:git:git://github.com/naver/spring-jdbc-plus.git"
99+
developerConnection "scm:git:git://github.com/naver/spring-jdbc-plus.git"
100+
url "git://github.com/naver/spring-jdbc-plus.git"
101+
}
102+
103+
licenses {
104+
license {
105+
name "The Apache License, Version 2.0"
106+
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
107+
}
108+
}
109+
110+
developers {
111+
developer {
112+
id "mhyeon.lee"
113+
name "Myeonghyeon Lee"
114+
115+
}
116+
}
117+
}
118+
}
119+
}
120+
}
121+
}

gradle/wrapper/gradle-wrapper.jar

54.9 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed Apr 08 13:12:22 KST 2020
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
3+
distributionBase=GRADLE_USER_HOME
4+
distributionPath=wrapper/dists
5+
zipStorePath=wrapper/dists
6+
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)