File tree Expand file tree Collapse file tree 3 files changed +82
-0
lines changed
src/test/java/com/codingapi/simplemybatis Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 6464 <artifactId >commons-lang3</artifactId >
6565 </dependency >
6666
67+ <dependency >
68+ <groupId >org.junit.jupiter</groupId >
69+ <artifactId >junit-jupiter-api</artifactId >
70+ <version >5.6.2</version >
71+ <scope >test</scope >
72+ </dependency >
73+
6774
6875 </dependencies >
6976
Original file line number Diff line number Diff line change 1+ package com .codingapi .simplemybatis .entity ;
2+
3+ import javax .persistence .*;
4+
5+ @ Table (name = "t_test" )
6+ public class Demo {
7+
8+ @ Id
9+ @ GeneratedValue (strategy = GenerationType .IDENTITY )
10+ private Long id ;
11+
12+ private String name ;
13+
14+ @ Column (name = "s_demo" )
15+ private String test ;
16+
17+ private boolean flag ;
18+
19+ public boolean isFlag () {
20+ return flag ;
21+ }
22+
23+ public void setFlag (boolean flag ) {
24+ this .flag = flag ;
25+ }
26+
27+ public Long getId () {
28+ return id ;
29+ }
30+
31+ public void setId (Long id ) {
32+ this .id = id ;
33+ }
34+
35+ public String getName () {
36+ return name ;
37+ }
38+
39+ public void setName (String name ) {
40+ this .name = name ;
41+ }
42+
43+ public String getTest () {
44+ return test ;
45+ }
46+
47+ public void setTest (String test ) {
48+ this .test = test ;
49+ }
50+ }
Original file line number Diff line number Diff line change 1+ package com .codingapi .simplemybatis .parser ;
2+
3+ import com .codingapi .simplemybatis .entity .Demo ;
4+ import org .junit .jupiter .api .Test ;
5+
6+ import java .lang .reflect .InvocationTargetException ;
7+
8+
9+ public class SqlParserDemo {
10+
11+ @ Test
12+ public void save () throws InvocationTargetException , IllegalAccessException {
13+ Demo demo = new Demo ();
14+ demo .setName ("test" );
15+ demo .setFlag (false );
16+ demo .setTest ("123" );
17+
18+ TableParser tableParser = new TableParser (demo .getClass ());
19+ tableParser .parser (demo );
20+ SqlParser sqlParser = new SqlParser (tableParser .getTableInfo ());
21+ String sql = sqlParser .createInsertSql ();
22+ System .out .println (sql );
23+
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments