Braayy / LightORM

A lightweight and performant Java ORM alternative.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LightORM

LightORM

A lightweight and performant Java ORM alternative.

Java version GitHub stars Github Issues MIT License

LightORM has annotation processors so that all the integration code with the database is generated at the time of compilation, thus ensuring that you will not have any performance problems.

Getting Started

Setup dependencies

  • Maven
<dependencies>
    <dependency>
        <groupId>com.jpereirax.lightorm</groupId>
        <artifactId>core</artifactId>
        <version>0.1.2-BETA</version>
    </dependency>
</dependencies>

<!-- MavenCompiler Plugin -->

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <annotationProcessorPaths>
                    <annotationProcessorPath>
                        <groupId>com.jpereirax.lightorm</groupId>
                        <artifactId>processor</artifactId>
                        <version>0.1.2-BETA</version>
                    </annotationProcessorPath>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>
  • Gradle
dependencies {
    implementation 'com.jpereirax.lightorm:core:0.1.2-BETA'
    annotationProcessor 'com.jpereirax.lightorm:processor:0.1.2-BETA'
}

Samples

Connection Configuration

public class DBConfiguration {
    
    public void setupConnection() {
        DataSourceConfiguration configuration = DataSourceConfiguration.builder()
                .connectionType(ConnectionType.H2)
                .database("your_database")
                .maxPoolSize(1)
                .build();

        new DataSource(configuration).openConnection();
    }
}

Return Object

public class User {
    
    private String name;
    private Integer level;
    private String rank;
    
    // Needed to map the query result to the object.
    public User(String name, Integer level, String rank) {
        this.name = name;
        this.level = level;
        this.rank = rank;
    }
    
    // Other methods...
}

DataProvider

@DataProvider
public interface UserDataProvider {
    
    @Query("SELECT NAME, LEVEL, RANK FROM USER WHERE UUID = ?")
    User findByUUID(String uuid);
}



LightORM

About

A lightweight and performant Java ORM alternative.

License:MIT License


Languages

Language:Java 93.9%Language:Kotlin 6.1%