Pustike Persist
Persist is an object based persistence library. Using a simple configuration and annotation based entity mapping, it provides features like schema generation, sql query api to insert / update / delete objects and a fluent data finder api.
Using Java Persistence API is the standard approach to object persistence in Java based applications. And it is a comprehensive and complex API to implement and use. Using a JPA implementation for persistence can add lot of overhead to small/medium sized applications. So, Pustike Persist provides a simple api to perform common SQL queries using object metadata built using JPA like annotations.
Following are some of its key features:
- Repository configuration using dataSource and schema metadata
- Entity mapping to database table and fields to columns using annotations
- Database schema generation with indexes, foreign keys, constraints, etc using the mapping tool
- Allows field group definitions per entity to fetch or update only the required data
- Insert single/list of objects into database in batch and support update on conflict using excluded rows
- Update single/multiple objects in the database using the specified field group
- Select row data as object with the given identity and option to select them for update with lock
- Delete single/multiple objects
- A fluent Finder API to construct sql queries and fetch result data as objects
- Supported databases: PostgreSQL
- Requires Java 11 and has no external dependencies (~60kB in size)
Documentation: Latest javadocs is available here.
Todo:
- Write unit tests using test container
- More detailed documentation
- Support readOnly transactions
- Allow multiple schema definitions per repository
- Override field name when using field@fgName instead of adding both
- Finder API - add fetch(String fgName) as a method to reduce the number of overloaded fetch methods
- MappingTool - create ForeignKey column based on the type of @Id column
- MappingTool - if existing field metadata is changed, compare with the database and show warnings
- Add support for Composite primary key
- Implement L1 Cache to avoid creating same object multiple times
- Support more databases (MySQL, H2, HSQLDB, Derby)
Download
To add a dependency using Maven, use the following:
<dependency>
<groupId>io.github.pustike</groupId>
<artifactId>pustike-persist</artifactId>
<version>0.9.2</version>
</dependency>
Or, download the latest JAR
License
This library is published under the Apache License, Version 2.0