Skip to content

Commit 424d641

Browse files
committed
1.New version 2.0.0
2.Refactor code 3.Adapt to MySQL and SQLite databases
1 parent 38e430c commit 424d641

File tree

19 files changed

+957
-636
lines changed

19 files changed

+957
-636
lines changed

README.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
[![](https://img.shields.io/badge/license-Apache--2.0-%234377BF)](#license)
44

55

6-
## SQLite-Java
7-
``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.
88

99

1010
## Features
11-
+ Support for automatic table creation and addition columns.
11+
+ Support automatic creation of tables, addition of columns, and addition of indexes.
1212
+ Provide APIs for adding, deleting, modifying, and querying.
1313
+ Provides aggregate function APIs.
1414
+ APIs are simple, elegant and efficient to use.
@@ -22,7 +22,7 @@ repositories {
2222
}
2323
2424
dependencies {
25-
implementation 'com.github.artbits:sqlite-java:1.0.6'
25+
implementation 'com.github.artbits:orm-java:2.0.0'
2626
}
2727
```
2828
Maven:
@@ -34,16 +34,19 @@ Maven:
3434

3535
<dependency>
3636
<groupId>com.github.artbits</groupId>
37-
<artifactId>sqlite-java</artifactId>
38-
<version>1.0.6</version>
37+
<artifactId>orm-java</artifactId>
38+
<version>2.0.0</version>
3939
</dependency>
4040
```
4141

4242

4343
## Usage
44-
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.
4545
```java
46-
public class User extends DataSupport<User> {
46+
public class User {
47+
public Long id;
48+
@Column(index = true)
49+
public Long uid;
4750
public String name;
4851
public Integer age;
4952
public Boolean vip;
@@ -54,7 +57,8 @@ public class User extends DataSupport<User> {
5457
}
5558

5659

57-
public class Book extends DataSupport<Book> {
60+
public class Book {
61+
public Long id;
5862
public String name;
5963
public String author;
6064
public Double price;
@@ -65,9 +69,13 @@ public class Book extends DataSupport<Book> {
6569
}
6670
```
6771

68-
Connect to the database and load tables (automatically add tables and columns).
72+
Connect to the database and load tables (automatically add tables, columns and index).
6973
```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);
7179
db.tables(User.class, Book.class);
7280
```
7381

@@ -76,7 +84,7 @@ Insert data.
7684
// No need to set ID, ID will increase automatically when inserting data.
7785
User user = new User(u -> {u.name = "Lake"; u.age = 25; u.vip = true;});
7886
db.insert(user);
79-
user.printJson();
87+
DB.print(user);
8088
```
8189

8290
Update data.
@@ -166,6 +174,7 @@ int min2 = db.min(User.class, "age", "vip = ?", true).intValue();
166174

167175
## Links
168176
+ Thanks:
177+
+ [MySQL Connector/J](https://github.com/mysql/mysql-connector-j)
169178
+ [SQLite-JDBC](https://github.com/xerial/sqlite-jdbc)
170179
+ [QuickIO](https://github.com/artbits/quickio)
171180

build.gradle

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ plugins {
33
id 'maven-publish'
44
}
55

6-
group = 'com.github.artbits'
7-
version = '1.0.8'
6+
group = 'com.github.artbits.orm-java'
7+
version = '2.0.0'
88

99
repositories {
1010
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
11+
maven { url 'https://www.jitpack.io' }
1112
}
1213

1314
dependencies {
14-
implementation 'org.xerial:sqlite-jdbc:3.43.0.0'
15-
implementation 'com.google.code.gson:gson:2.10.1'
16-
testImplementation platform('org.junit:junit-bom:5.9.1')
15+
implementation 'org.apache.commons:commons-dbcp2:2.13.0'
16+
implementation 'com.mysql:mysql-connector-j:9.4.0'
17+
implementation 'org.xerial:sqlite-jdbc:3.50.3.0'
18+
19+
testImplementation platform('org.junit:junit-bom:5.10.0')
1720
testImplementation 'org.junit.jupiter:junit-jupiter'
1821
}
1922

@@ -32,9 +35,4 @@ publishing {
3235
from components.java
3336
}
3437
}
35-
}
36-
37-
wrapper {
38-
gradleVersion = "8.0"
39-
distributionType = Wrapper.DistributionType.ALL
4038
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#Sun Sep 03 17:55:37 CST 2023
1+
#Sun Sep 07 02:14:41 CST 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
4+
#distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
5+
#distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-9.0.0-milestone-9-bin.zip
6+
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.0-bin.zip
57
zipStoreBase=GRADLE_USER_HOME
68
zipStorePath=wrapper/dists

settings.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
rootProject.name = 'sqlite-java'
2-
1+
rootProject.name = 'orm-java'

src/main/java/com/github/artbits/jsqlite/Column.java

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

0 commit comments

Comments
 (0)