sproket/Persism
sproket/Persism has 154 GitHub stars and 6 forks. Star changes are not measured yet. Last checked 2026-11-14 04:37 UTC. Last push 2026-10-27.
Crecimiento de estrellas medido
- in 24h
- Recopilando historial
- in 7 days
- Recopilando historial
- in 15 days
- Recopilando historial
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
Acerca de
A zero ceremony ORM for Java
DatosREADME.md
Original
Release notes 2.3.0 -- Getting Started Guide
Table joins are now supported!
Welcome
Persism is a light weight, auto discovery, autoconfiguration, and convention over configuration ORM (Object Relational Mapping) library for Java 17 or later.
For Java 8 or later see the 1.x branch https://github.com/sproket/Persism/tree/persism1
<dependency>
<groupId>io.github.sproket</groupId>
<artifactId>persism</artifactId>
<version>2.3.0</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
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 something is outside convention.
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 about 100k and has zero dependencies however it will utilize logging based on whatever is available at runtime - SLF4J, LOG4J2, LOG4J or JUL.
Have a look here for the getting started guide, code coverage and Javadoc
Compile
To run tests for in memory databases H2, HSQLDB, Derby and SQLite
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!
Explorar proyectos relacionados
Asabeneh/30-Days-Of-Python
El reto de programación 30 Days of Python es una guía paso a paso para aprender el lenguaje de programación Python en 30 días. Este reto puede llevar más de 100 días. Sigue tu propio ritmo. Estos vídeos también pueden ayudarte: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,711 estrellasgrafana/grafana
Plataforma abierta y componible de observabilidad y visualización de datos. Visualiza métricas, registros y trazas de múltiples fuentes, como Prometheus, Loki, Elasticsearch, InfluxDB, Postgres y muchas más.
77,894 estrellasredis/redis
Para los desarrolladores que crean aplicaciones en tiempo real basadas en datos, Redis es la opción preferida, la más rápida y la de más funciones como caché, servidor de estructuras de datos y motor de consultas de documentos y vectores.
77,491 estrellasapache/superset
Apache Superset es una plataforma de visualización y exploración de datos.
75,522 estrellas