Skip to content

Commit 8d3a1bb

Browse files
committed
0.0.17. 1. Fix bug of Deleter 2. Jimmer-sql demo uses spring-shell
1 parent b176803 commit 8d3a1bb

File tree

22 files changed

+578
-251
lines changed

22 files changed

+578
-251
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
HELP.md
2+
*.log
23
.gradle
34
.DS_Store
45
build/

example/jimmer-core/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ plugins {
33
}
44

55
group 'org.babyfish.jimmer.example.core'
6-
version '0.0.9'
6+
version '0.0.17'
77

88
repositories {
99
mavenCentral()
1010
}
1111

1212
dependencies {
1313

14-
implementation 'org.babyfish.jimmer:jimmer-core:0.0.9'
15-
annotationProcessor 'org.babyfish.jimmer:jimmer-apt:0.0.9'
14+
implementation 'org.babyfish.jimmer:jimmer-core:0.0.17'
15+
annotationProcessor 'org.babyfish.jimmer:jimmer-apt:0.0.17'
1616

1717
implementation 'javax.validation:validation-api:2.0.1.Final'
1818
}

example/jimmer-sql-graphql/build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'org.babyfish.jimmer.sql.example'
8-
version = '0.0.1-SNAPSHOT'
8+
version = '0.0.17'
99
sourceCompatibility = '1.8'
1010

1111
repositories {
@@ -14,9 +14,8 @@ repositories {
1414

1515
dependencies {
1616

17-
implementation 'org.babyfish.jimmer:jimmer-core:0.0.14'
18-
implementation 'org.babyfish.jimmer:jimmer-sql:0.0.14'
19-
annotationProcessor 'org.babyfish.jimmer:jimmer-apt:0.0.14'
17+
implementation 'org.babyfish.jimmer:jimmer-sql:0.0.17'
18+
annotationProcessor 'org.babyfish.jimmer:jimmer-apt:0.0.17'
2019

2120
implementation 'org.springframework.boot:spring-boot-starter-graphql'
2221
implementation 'org.springframework.boot:spring-boot-starter-web'

example/jimmer-sql/build.gradle

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
plugins {
2+
// Spring Shell Boot report errors on 2.7.0, so use 2.5.7
3+
id 'org.springframework.boot' version '2.5.7'
4+
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
25
id 'java'
36
}
47

58
group 'org.babyfish.jimmer.example.sql'
6-
version '0.0.9'
9+
version '0.0.17'
710

811
repositories {
912
mavenCentral()
1013
}
1114

1215
dependencies {
13-
implementation 'org.babyfish.jimmer:jimmer-core:0.0.15'
14-
implementation 'org.babyfish.jimmer:jimmer-sql:0.0.15'
15-
annotationProcessor 'org.babyfish.jimmer:jimmer-apt:0.0.15'
1616

17-
implementation 'javax.validation:validation-api:2.0.1.Final'
18-
implementation 'javax.persistence:javax.persistence-api:2.2'
17+
implementation 'org.babyfish.jimmer:jimmer-core:0.0.17'
18+
implementation 'org.babyfish.jimmer:jimmer-sql:0.0.17'
19+
annotationProcessor 'org.babyfish.jimmer:jimmer-apt:0.0.17'
20+
21+
implementation 'org.springframework.boot:spring-boot-starter'
22+
implementation 'org.springframework.shell:spring-shell-starter:2.0.1.RELEASE'
23+
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
1924

20-
implementation 'com.zaxxer:HikariCP:5.0.1'
2125
runtimeOnly 'com.h2database:h2:2.1.212'
2226
}
2327

Lines changed: 5 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,12 @@
11
package org.babyfish.jimmer.sql.example;
22

3-
import org.babyfish.jimmer.sql.ast.Expression;
4-
import org.babyfish.jimmer.sql.ast.query.ConfigurableTypedRootQuery;
5-
import org.babyfish.jimmer.sql.ast.query.OrderMode;
6-
import org.babyfish.jimmer.sql.ast.query.TypedRootQuery;
7-
import org.babyfish.jimmer.sql.ast.tuple.Tuple3;
8-
import org.babyfish.jimmer.sql.example.model.*;
9-
10-
import java.io.IOException;
11-
import java.util.List;
12-
13-
import static org.babyfish.jimmer.sql.example.AppContext.*;
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
145

6+
@SpringBootApplication
157
public class App {
168

17-
public static void main(String[] args) throws IOException {
18-
try {
19-
showData(
20-
Console.readLine("Please input name filter of current book object (Optional): "),
21-
Console.readLine("Please input name filter of parent store object (Optional): "),
22-
Console.readLine("Please input name filter of child author object (Optional): "),
23-
2
24-
);
25-
} finally {
26-
AppContext.close();
27-
}
28-
}
29-
30-
private static void showData(
31-
String name,
32-
String storeName,
33-
String authorName,
34-
int pageSize
35-
) {
36-
ConfigurableTypedRootQuery<BookTable, Tuple3<Book, Integer, Integer>> query =
37-
SQL_CLIENT.createQuery(BookTable.class, (q, book) -> {
38-
if (name != null && !name.isEmpty()) {
39-
q.where(book.name().ilike(name));
40-
}
41-
if (storeName != null && !storeName.isEmpty()) {
42-
q.where(book.store().name().ilike(storeName));
43-
}
44-
if (authorName != null && !authorName.isEmpty()) {
45-
q.where(
46-
book.id().in(
47-
q.createSubQuery(AuthorTableEx.class, (sq, author) -> {
48-
sq.where(
49-
author.firstName().ilike(authorName).or(
50-
author.lastName().ilike(authorName)
51-
)
52-
);
53-
return sq.select(author.books().id());
54-
})
55-
)
56-
);
57-
}
58-
q.orderBy(book.name());
59-
q.orderBy(book.edition(), OrderMode.DESC);
60-
return q.select(
61-
book.fetch(
62-
BookFetcher.$
63-
.allScalarFields()
64-
.store(BookStoreFetcher.$.allScalarFields())
65-
.authors(AuthorFetcher.$.allScalarFields())
66-
),
67-
Expression.numeric().sql(
68-
Integer.class,
69-
"rank() over(order by %e desc)",
70-
it -> it.expression(book.price())
71-
),
72-
Expression.numeric().sql(
73-
Integer.class,
74-
"rank() over(partition by %e order by %e desc)",
75-
it -> it
76-
.expression(book.store().id())
77-
.expression(book.price())
78-
)
79-
);
80-
});
81-
82-
TypedRootQuery<Long> countQuery = query
83-
.reselect((oldQuery, book) -> oldQuery.select(book.count()))
84-
.withoutSortingAndPaging();
85-
86-
int rowCount = countQuery.execute().get(0).intValue();
87-
int pageCount = (rowCount + pageSize - 1) / pageSize;
88-
System.out.println("-------------------------------------------------");
89-
System.out.println("Total row count: " + rowCount + ", pageCount: " + pageCount);
90-
System.out.println("-------------------------------------------------");
91-
System.out.println();
92-
93-
for (int pageNo = 1; pageNo <= pageCount; pageNo++) {
94-
System.out.println("-----------Page no: " + pageNo + "-----------");
95-
System.out.println();
96-
int offset = pageSize * (pageNo - 1);
97-
List<Tuple3<Book, Integer, Integer>> rows =
98-
query
99-
.limit(pageSize, offset)
100-
.execute();
101-
for (Tuple3<Book, Integer, Integer> row : rows) {
102-
System.out.println("book object: " + row._1());
103-
System.out.println("global price rank: " + row._2());
104-
System.out.println("price rank in own store: " + row._3());
105-
System.out.println();
106-
}
107-
}
9+
public static void main(String[] args) {
10+
SpringApplication.run(App.class, args);
10811
}
10912
}

example/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/example/AppContext.java

Lines changed: 0 additions & 94 deletions
This file was deleted.

example/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/example/Console.java

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.babyfish.jimmer.sql.example.cfg;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.fasterxml.jackson.databind.ObjectWriter;
5+
import org.babyfish.jimmer.jackson.ImmutableModule;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
9+
@Configuration
10+
public class JacksonConfig {
11+
12+
@Bean
13+
public ObjectWriter prettyWriter() {
14+
return new ObjectMapper()
15+
.registerModule(new ImmutableModule())
16+
.writerWithDefaultPrettyPrinter();
17+
}
18+
}

0 commit comments

Comments
 (0)