All Projects → gaarason → database-all

gaarason / database-all

Licence: MIT license
Eloquent ORM for Java 【database-spring-boot-starter】

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to database-all

Vertx Maven Starter
Maven project template for Vert.x
Stars: ✭ 135 (-10.6%)
Mutual labels:  maven, starter
CodexMicroORM
An alternative to ORM's such as Entity Framework, offers light-weight database mapping to your existing CLR objects. Visit "Design Goals" on GitHub to see more rationale and guidance.
Stars: ✭ 32 (-78.81%)
Mutual labels:  orm-framework, orm-library
Venflow
A brand new, fast and lightweight ORM, build for PostgreSQL.
Stars: ✭ 162 (+7.28%)
Mutual labels:  orm-framework, orm-library
jds
Jenesis Data Store: a dynamic, cross platform, high performance, ORM data-mapper. Designed to assist in rapid development and data mining
Stars: ✭ 17 (-88.74%)
Mutual labels:  orm-framework, orm-library
nim-gatabase
Connection-Pooling Compile-Time ORM for Nim
Stars: ✭ 103 (-31.79%)
Mutual labels:  orm-framework, orm-library
maven-archetypes-catalog-plugin
A plugin to enable IntelliJ IDEA to fetch external Maven Archetype Catalog files
Stars: ✭ 19 (-87.42%)
Mutual labels:  maven
xml-maven-plugin
XML Maven Plugin
Stars: ✭ 18 (-88.08%)
Mutual labels:  maven
monorepo
Structure and workflows of our internal git-maven-monorepo
Stars: ✭ 16 (-89.4%)
Mutual labels:  maven
strapi-starter-nuxt-e-commerce
Strapi Starter Nuxt.js E-commerce
Stars: ✭ 170 (+12.58%)
Mutual labels:  starter
mcs
Search the Maven Central Repository from your command line!
Stars: ✭ 61 (-59.6%)
Mutual labels:  maven
betca-spring
BETCA (Spring). Back-end con Tecnologías de Código Abierto, versión Java-Spring
Stars: ✭ 27 (-82.12%)
Mutual labels:  maven
mvnsh
Maven Shell
Stars: ✭ 50 (-66.89%)
Mutual labels:  maven
Desktop-Applications-JavaFX
JavaFX Open Source Projects
Stars: ✭ 69 (-54.3%)
Mutual labels:  orm-framework
hephaestus-engine
Render, animate and interact with custom entity models in Minecraft: Java Edition servers
Stars: ✭ 77 (-49.01%)
Mutual labels:  model
native-build-tools
Native-image plugins for various build tools
Stars: ✭ 168 (+11.26%)
Mutual labels:  maven
noise-php
A starter-kit for your PHP project.
Stars: ✭ 52 (-65.56%)
Mutual labels:  starter
concurrent-resource
A header-only C++ library that allows easily creating thread-safe, concurrency friendly resources.
Stars: ✭ 17 (-88.74%)
Mutual labels:  threadsafe
maven-sources
Apache Maven Sources
Stars: ✭ 59 (-60.93%)
Mutual labels:  maven
bintray-upload-plugin
📦 Insanely easy way to upload your Android Library to Bintray/JCenter
Stars: ✭ 18 (-88.08%)
Mutual labels:  maven
vite-primevue-starter
VUE 3 Starter project for using primevue 3 with Vite 2 - Pages, Layouts, Validation
Stars: ✭ 37 (-75.5%)
Mutual labels:  starter

database

Eloquent ORM for Java

简介

  • 让连接数据库以及对数据库进行增删改查操作变得非常简单,不论希望使用原生 SQL、还是查询构造器,还是 Eloquent ORM。

  • Eloquent ORM 提供一个美观、简单的与数据库打交道的 ActiveRecord 实现,每张数据表都对应一个与该表数据结构对应的实体(Entity),以及的进行交互的模型(Model),通过模型类,你可以对数据表进行查询、插入、更新、删除等操作,并将结果反映到实体实例化的 java 对象中。

  • 对于关联关系 Eloquent ORM 提供了富有表现力的声明方式,与简洁的使用方法,并专注在内部进行查询与内存优化,在复杂的关系中有仍然有着良好的体验。

  • 兼容于其他常见的 ORM 框架, 以及常见的数据源 (DataSource)

目录

  • 以如下的方式在程序中查询数据
  • 查询 model.newQuery().select().where().get().toObject();
  • 更新 model.newQuery().data().where().update();
  • 删除 model.newQuery().where().delete();
  • 新增 model.newQuery().column().value().insert();
// 查询id为4的一条数据 select * from student where id = 4 limit 1
Student student = studentModel.find(4).toObject();

// 表达式列名风格 select name,age from student where id in (1,2,3)
List<Student> Students = studentModel.newQuery().whereIn(Student::getId, 1,2,3)
    .select(Student::getName).select(Student::getAge)
    .get().toObjectList();

// 稍复杂嵌套的语句 select id,name from student where id=3 or(age>11 and id=7 and(id between 4 and 10 and age>11))
List<Student> Students = studentModel.newQuery().where("id", "3").orWhere(
    builder -> builder.where("age", ">", "11").where("id", "7").andWhere(
        builder2 -> builder2.whereBetween("id", "4", "10").where("age", ">", "11")
    )
).select("id", "name").get().toObjectList();


// 关联查询 找出学生们的老师们的父亲们的那些房子
List<Student> Students = studentModel.newQuery().whereIn("id", "1","2","3").get().with("teacher.father.house").toObjectList();


// 增加关联 给id为8的学生增加3名老师(id分别为1,2,3)
studentModel.findOrFail(8).bind("teachers").attach( teacherModel.findMany(1,2,3) );

spring boot 快速开始

1.引入仓库 pom.xml

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

2.引入依赖 pom.xml

<dependency>
    <groupId>com.github.gaarason.database-all</groupId>
    <artifactId>database-spring-boot-starter</artifactId>
    <version>RELEASE</version>
</dependency>

3.配置连接 application.properties

spring.datasource.url=jdbc:mysql://mysql.local/test_master_0?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=true&autoReconnect=true&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# 使用你喜欢的 datasource, 这边增加了 DruidDataSource 的支持, 使其符合 Spring 的指定风格
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource

# 雪花算法工作id, 默认是0
gaarason.database.snow-flake.worker-id=1

# 包扫描路径, 默认是`@SpringBootApplication`所在的包
gaarason.database.scan.packages=you.package1,you.package2

4.快速开始

@Resource
GeneralModel generalModel;

@Test
public void 简单查询() {
    // select * from student where id=3 limit 1
    Record<GeneralModel.Table, Object> record = generalModel.newQuery().from("student").where("id", "3").firstOrFail();
    
    Map<String, Object> stringObjectMap = record.toMap();
    
    System.out.println(stringObjectMap);
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].