/worm

Create and manage mysql tables with Java Class

Primary LanguageJava

Worm

It's a Java ORM for MySQL


Topics


🪱 What is Worm?

Worm is a Java ORM for Mysql, you can make simple query using:

User.java:

public class User extends Entity {
    @Field(unique = true, autoGenerate = true)
    public UUID userId;
    @Field
    public String name;
}

Main.java:

User user = Worm.of(User.class).findUnique("07e09b83-83bb-413c-bfb5-d64e8742f8f0");

🔧 Installation

Installation with maven

First, add Worm's repository into pom.xml:

<repositories>
    ...
    <repository>
        <id>worm</id>
        <url>https://repo.gump.dev/releases/</url>
    </repository>
</repositories>

Then, add Worm's dependency too:

<dependencies>
    ...
    <dependency>
        <groupId>dev.gump</groupId>
        <artifactId>worm</artifactId>
        <version>1.1.2</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

Installation with Gradle

First, add Worm's repository into build.gradle:

repositories {
    ...
    mavenCentral()
    maven {
        name = 'worm'
        url = 'https://repo.gump.dev/releases/'
    }
}

Then, add Worm's dependency too:

    dependencies {
        ...
        compile 'dev.gump:worm:1.1.2'
    }

(i don't know if this is right, i don't use Gradle :P)


📝 Getting Started

To get started we need to start Worm and declare your connection, use in main class:

public static void main(String[] args) {
    WormConnection connection = new WormConnection(host, port, database, user, password);
    WormConnector.init(connection);
}

Then create a class that extends Entity:

public class User extends Entity {
    @Field(unique=true, autoGenerate = true)
    public UUID userId; 
    @Field
    public String name;
    @Field(length=50)
    public String email;
}

Now we register the table in Worm:

public static void main(String[] args) {
    Worm.getRegistry().registerTable(User.class); // needs be before Worm.init()
        
    WormConnection connection = new WormConnection(host, port, database, user, password);
    Worm.init(connection);
}

Now you can use:

  User user = Worm.of(User.class).findUnique("87bf4ec7-9051-47a1-b9f4-eea9b9ed8959");

If you wanna learn more Click here to see documentation


🤔 FAQ

  • Why you created that? Cuz is so boring to create SQL querys and treat on Java, and I'm lazy
  • I Found a BUG! Click here and open an issue
  • Can I help with the project? Sure! just send your PR :D
  • Can I contact you? Yep, send email to contact@gump.dev

🙏 Thanks

Thanks to HikariCP, Mysql Connector Java and slf4j