You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
``SQLite-Java`` is a Java ORM for SQLite databases. Using ``SQLite-JDBC`` as the driver at the bottom. It provides simple and efficient APIs without writing a large number of SQL statements. You only need to know the basics of SQL to get started.
6
+
## ORM-Java
7
+
``ORM-Java`` is an ORM used for SQLite or MySQL databases. Using ``JDBC`` as the driver at the bottom level. It provides a simple and efficient API without the need to write a large number of SQL statements. You only need to know the basics of SQL to get started.
8
8
9
9
10
10
## Features
11
-
+ Support for automatic table creation and addition columns.
11
+
+ Support automatic creation of tables, addition of columns, and addition of indexes.
12
12
+ Provide APIs for adding, deleting, modifying, and querying.
Let Java classes be mapped into database tables. extends ``DataSupport`` class. The fields ``id``, ``createdAt``, and ``updatedAt`` are internal fields, please read them only when using them.
44
+
Let Java classes be mapped into database tables. The ``id`` field is a default required field.
45
45
```java
46
-
publicclassUserextendsDataSupport<User> {
46
+
publicclassUser {
47
+
publicLong id;
48
+
@Column(index=true)
49
+
publicLong uid;
47
50
publicString name;
48
51
publicInteger age;
49
52
publicBoolean vip;
@@ -54,7 +57,8 @@ public class User extends DataSupport<User> {
54
57
}
55
58
56
59
57
-
publicclassBookextendsDataSupport<Book> {
60
+
publicclassBook {
61
+
publicLong id;
58
62
publicString name;
59
63
publicString author;
60
64
publicDouble price;
@@ -65,9 +69,13 @@ public class Book extends DataSupport<Book> {
65
69
}
66
70
```
67
71
68
-
Connect to the database and load tables (automatically add tablesand columns).
72
+
Connect to the database and load tables (automatically add tables, columns and index).
69
73
```java
70
-
DB db =DB.connect("database/example.db");
74
+
Config config =Config.of(c -> {
75
+
c.driver =Config.Driver.SQLITE;
76
+
c.url ="jdbc:sqlite:example.db";
77
+
});
78
+
DB db =DB.connect(config);
71
79
db.tables(User.class, Book.class);
72
80
```
73
81
@@ -76,7 +84,7 @@ Insert data.
76
84
// No need to set ID, ID will increase automatically when inserting data.
77
85
User user =newUser(u -> {u.name ="Lake"; u.age =25; u.vip =true;});
0 commit comments