All Projects → sproket → Persism

sproket / Persism

Licence: BSD-3-Clause License
A zero ceremony ORM for Java

Programming Languages

TSQL
950 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Persism

orm-qt
Object Relation Mapping with Qt library
Stars: ✭ 32 (-66.67%)
Mutual labels:  orm-framework
jds
Jenesis Data Store: a dynamic, cross platform, high performance, ORM data-mapper. Designed to assist in rapid development and data mining
Stars: ✭ 17 (-82.29%)
Mutual labels:  orm-framework
active-persistence
Active Persistence is a implementation of Active Record Query Interface for JPA that makes it easy and fun.
Stars: ✭ 14 (-85.42%)
Mutual labels:  orm-framework
GoGonicEcommerceApi
Ecommerce Rest API application built in Go with Gin Gonic + Gorm
Stars: ✭ 81 (-15.62%)
Mutual labels:  orm-framework
database-all
Eloquent ORM for Java 【database-spring-boot-starter】
Stars: ✭ 151 (+57.29%)
Mutual labels:  orm-framework
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 (-66.67%)
Mutual labels:  orm-framework
Desktop-Applications-JavaFX
JavaFX Open Source Projects
Stars: ✭ 69 (-28.12%)
Mutual labels:  orm-framework
postmodel
ORM library for Python 3.6+, asyncio. Provides Django ORM like API.
Stars: ✭ 15 (-84.37%)
Mutual labels:  orm-framework
nim-gatabase
Connection-Pooling Compile-Time ORM for Nim
Stars: ✭ 103 (+7.29%)
Mutual labels:  orm-framework
Venflow
A brand new, fast and lightweight ORM, build for PostgreSQL.
Stars: ✭ 162 (+68.75%)
Mutual labels:  orm-framework
jdbcTemplatePlus
基于SpringJdbcTemplate的ORM框架,比Mybatis更方便,更简单,仅需定义Model就可支持各种SQL查询和动态SQL,不再用拼写XML文件和SQL语句,可以通过各种注解式插件扩展,目前主要支持Mysql数据库
Stars: ✭ 25 (-73.96%)
Mutual labels:  orm-framework
Neo
Orm框架:基于ActiveRecord思想开发的至简化的java的Orm框架
Stars: ✭ 35 (-63.54%)
Mutual labels:  orm-framework
php-orm-benchmark
The benchmark to compare performance of PHP ORM solutions.
Stars: ✭ 82 (-14.58%)
Mutual labels:  orm-framework
entitype
An ORM framework for Typescript that lets you fluently query the database with a strong typed programming interface.
Stars: ✭ 12 (-87.5%)
Mutual labels:  orm-framework
go-firestorm
Simple Go ORM for Google/Firebase Cloud Firestore
Stars: ✭ 39 (-59.37%)
Mutual labels:  orm-framework
mars
Mars - ODM Framework for MongoDB (MongoDB ODM Java )
Stars: ✭ 35 (-63.54%)
Mutual labels:  orm-framework
fastquery
FastQuery(Method of fast database query) 基于Java语言. 他的使命是:简化Java操作数据层.做为一个开发者,仅仅只需要设计编写DAO接口即可,在项目初始化阶段采用ASM生成好实现类. 因此,开发代码不得不简洁而优雅.从而,大幅度提升开发效率.
Stars: ✭ 63 (-34.37%)
Mutual labels:  orm-framework
GoBatis
An easy ORM tool for Golang, support MyBatis-Like XML template SQL
Stars: ✭ 113 (+17.71%)
Mutual labels:  orm-framework
Mybatis Plus
An powerful enhanced toolkit of MyBatis for simplify development
Stars: ✭ 12,132 (+12537.5%)
Mutual labels:  orm-framework
node-typescript-restify
Example Application
Stars: ✭ 26 (-72.92%)
Mutual labels:  orm-framework

Release notes Getting Started Guide

Welcome

Persism is a wood simple, auto discovery, auto-configuration, and convention over configuration ORM (Object Relational Mapping) library for Java 17 or later.

For Java 8 see the 1.x branch https://github.com/sproket/Persism/tree/persism1

<dependency>
    <groupId>io.github.sproket</groupId>
    <artifactId>persism</artifactId>
    <version>2.0.1</version>
</dependency>
import static net.sf.persism.Parameters.*;
import static net.sf.persism.SQL.*;

Connection con = DriverManager.getConnection(url, username, password);

// Instantiate a Persism session object with the connection
Session session = new Session(con);

List<Customer> list = session.query(Customer.class, sql("select * from Customers where CUST_NAME = ?"), params("Fred"));
// or
List<Customer> list = session.query(Customer.class, proc("sp_FindCustomers(?)"), params("Fred"));

Customer customer;
customer = session.fetch(Customer.class, sql("select * from Customers where CUST_NAME = ?"), params("Fred"));
// or   
customer = session.fetch(Customer.class, proc("sp_FindCustomer(?)"), params("Fred"));
if (customer != null) {
    // etc...
}

// You don't need the SELECT parts for Views or Tables
List<Customer> list = session.query(Customer.class, where("CUST_NAME = ?"), params("Fred"));

// You can reference the property names instead of the column names - just use :propertyName 
List<Customer> list = session.query(Customer.class, where(":name = ?"), params("Fred"));

// Order by is also supported with where() method
List<Customer> list = session.query(Customer.class, where(":name = ? ORDER BY :lastUpdated"), params("Fred"));

// Named parameters are also supported - just use @name
SQL sql = where("(:firstname = @name OR :company = @name) and :lastname = @last");
customer = session.fetch(Customer.class, sql, params(Map.of("name", "Fred", "last", "Flintstone")));

// fetch an existing instance
Customer customer = new Customer();
customer.setCustomerId(123);
if (session.fetch(customer)) {
    // customer found and initialized
} 

// Supports basic types
String result = session.fetch(String.class, sql("select Name from Customers where ID = ?"), params(10));

// Fetch a count as an int - Enums are supported 
int count = session.fetch(int.class, sql("select count(*) from Customers where Region = ?"), params(Region.West));

// Insert - get autoinc
Customer customer = new Customer();
customer.setCustomerName("Fred");
customer.setAddress("123 Sesame Street");

session.insert(customer); 

// Inserted and new autoinc value assigned 
assert customer.getCustomerId() > 0

// Update
customer.setCustomerName("Barney");
sesion.update(customer); // Update Customer   

// Delete
session.delete(customer);

// Handles transactions
session.withTransaction(() -> {
    Contact contact = getContactFromSomewhere();
    contact.setIdentity(randomUUID);
    session.insert(contact);
    
    contact.setContactName("Wilma Flintstone");
    
    session.update(contact);
    session.fetch(contact);
});

Simple

The API for Persism is small. Mostly you just need a Connection and a Persism Session object, and you're good to go. Your POJOs can have optional annotations for table and column names and can optionally implement a Persistable interface for where you need to track changes to properties for UPDATE statements.

Auto-Discovery

Persism figures things out for you. Create a table, write a JavaBean, run a query. Persism uses simple mapping rules to find your table and column names and only requires an annotation where it can’t find a match.

Convention over configuration

Persism requires no special configuration. Drop the JAR into your project and go.

Persism has annotations though they are only needed where something is outside the conventions. In most cases you probably don't even need them.

Persism can usually detect the table and column mappings for you including primary/generated keys and columns with defaults.

Supports most common databases

Derby, Firebird, H2, HSQLDB, Informix, MSAccess, MSSQL, MySQL/MariaDB, Oracle (12+), PostgreSQL, SQLite.

Smart

Persism will do the correct thing by default. Persism understands that your class is called Customer and your table is called CUSTOMERS. It understands that your table column is CUSTOMER_ID and your property is customerId.

Persism understands when your class is called Category and your table is called CATEGORIES. No problem. No need to annotate for that. Persism uses annotations as a fall back – annotate only when something is outside the conventions.

Tiny

Persism is under 100k. Yeah, fit it on a floppy if you want. Persism has Zero dependencies however it will utilize logging based on whatever is available at runtime - SLF4J, LOG4J or JUL.

Have a look here for the getting started guide, code coverage and Javadoc

Compile

To run tests only basic tests: in memory databases (H2, HSSQL, Derby) + sqlite (faster)

mvn clean test

To run basic tests + testContainers based tests (postgresql, mysql, mariadb, firebird). Need docker installed.

mvn clean test -P include-test-containers-db

To run tests for every supported database. Needs Oracle up and running

mvn clean test -P all-db

To generate surefire reports with every database but Oracle (in target/site/surefire-report.html)

mvn clean test surefire-report:report -P include-test-containers-db

Thanks!

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].