Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

JanHolger/AJORM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AJORM

Another Java ORM

DISCONTINUED

AJORM is now part of JavaWebStack This repository still contains the old version which isn't maintained anymore. Consider using JavaWebStack instead.

Introduction

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.

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.

I finally decided to make an own ORM that fits my needs and here it is.

Documentation

Docs for version 2 will follow as soon as version 2 is fully stable.

Example usage

Model

@Dates @SoftDelete
class User extends Model {
  @Column
  int id;
  @Column
  String name;
  @Column
  Timestamp createdAt;
  @Column
  Timestamp updatedAt;
  @Column
  Timestamp deletedAt;
}

Usage

//Create connection, initialize repos
SQL sql = new MySQL("localhost",3306,"mydb","myuser","changeme1234");
AJORMConfig config = new AJORMConfig().setDefaultSize(255); //optional
Repo<User> repo = AJORM.register(User.class, sql, config);

//Create the table if it doesn't exist (optional)
repo.migrate();

//Print all usernames
for(User user : Repo.get(User.class).all()){
    System.out.println(user.name);
}

Maven

Repository

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>

Dependency

<dependency>
    <groupId>com.github.JanHolger</groupId>
    <artifactId>AJORM</artifactId>
    <version>COMMIT_HASH</version>
</dependency>

Driver

You also need to add the driver you want to use. AJORM comes with a wrapper for com.mysql.jdbc.Driver, but you can also create an own wrapper implementing the interface SQL. (For some reason I needed a pretty old driver version to connect to some servers, so I thought it would be better to link the old version here)

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
    <scope>compile</scope>
</dependency>

About

Another Java ORM

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages