Skip to content

Commit aca897f

Browse files
authored
Create README.md
1 parent b7d9ea4 commit aca897f

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# AJORM
2+
Another Java ORM
3+
4+
## Introduction
5+
When it came to using an ORM Lib in java I used ORMLite before. It worked quite well, but I didn't like the query builder.
6+
7+
Another thing was that I wanted to have control over the JDBC Wrapper to have a simple way of implementing an auto-reconnect function, if it gets disconnected for some reason.
8+
9+
I finally decided to make an own ORM that fits my needs and here it is.
10+
11+
## Example usage
12+
13+
### Model
14+
```java
15+
@DatabaseTable("users")
16+
class User {
17+
@DatabaseField(id = true, ai = true)
18+
int id;
19+
@DatabaseField
20+
String name;
21+
public User(){
22+
23+
}
24+
public User(String name){
25+
this.name = name;
26+
}
27+
}
28+
```
29+
### Repository
30+
```java
31+
class Database {
32+
public Table users;
33+
public Database(SQL sql){
34+
this.users = new Table<User,Integer>(sql,User.class);
35+
}
36+
public List<User> getAllUsers(){
37+
return users.queryForAll();
38+
}
39+
}
40+
```
41+
### Usage
42+
```java
43+
//Create connection, initialize tables
44+
Database db = new Database(new MySQL("localhost",3306,"mydb","myuser","changeme1234"));
45+
//Print all usernames
46+
for(User user : db.getAllUsers())
47+
System.out.println(user.name);
48+
```
49+
50+
## Maven
51+
52+
### Repository
53+
```xml
54+
<respository>
55+
<id>bebendorf</id>
56+
<url>http://repo.bebendorf.eu/</url>
57+
</repository>
58+
```
59+
### Dependency
60+
```xml
61+
<dependency>
62+
<groupId>eu.bebendorf</groupId>
63+
<artifactId>AJORM</artifactId>
64+
<version>1.0</version>
65+
</dependency>
66+
```
67+
### JitPack
68+
You can alternativly use jitpack if my repo is down or just not reliable enough for your needs.
69+
https://jitpack.io/#JanHolger/AJORM

0 commit comments

Comments
 (0)