A lightweight Java ORM.
⚠️ Warning: This project is heavily in development. APIs may change without notice.
dependencies {
implementation("io.github.oskarscot:volt-core:0.0.3")
}dependencies {
implementation 'io.github.oskarscot:volt-core:0.0.3'
}<dependency>
<groupId>io.github.oskarscot</groupId>
<artifactId>volt-core</artifactId>
<version>0.0.3</version>
</dependency>@Entity("users")
public class User {
@Identifier(type = PrimaryKeyType.NUMBER, generated = true)
private Long id;
@NamedField(name = "email_address")
private String email;
private String name;
private boolean active;
public User() {}
// getters and setters
}HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:postgresql://localhost:5432/mydb");
config.setUsername("user");
config.setPassword("password");
Volt volt = VoltFactory.createVolt(config);
volt.registerEntity(User.class);// Create
User user = new User();
user.setName("John");
user.setEmail("john@example.com");
user.setActive(true);
Result<User, VoltError> result = volt.save(user);
if (result.isSuccess()) {
System.out.println("Saved with ID: " + result.getValue().getId());
}
// Find by ID
Result<User, VoltError> found = volt.findById(User.class, 1L);try (Transaction tx = volt.beginTransaction()) {
User user1 = new User("Alice", "alice@example.com");
User user2 = new User("Bob", "bob@example.com");
tx.save(user1);
tx.save(user2);
tx.commit();
}try (Transaction tx = volt.beginTransaction()) {
Query query = Query.where("active").eq(true)
.and("name").like("J%");
Result<List<User>, VoltError> result = tx.findAllBy(User.class, query);
if (result.isSuccess()) {
result.getValue().forEach(u -> System.out.println(u.getName()));
}
tx.commit();
}- Entity mapping with annotations
- CRUD operations
- Transaction support
- Fluent query builder
- Type converters
- Connection pooling (HikariCP)
- Relationships (OneToMany, ManyToOne)
- Migrations
- Caching
- More database support
- Java 21+
- PostgreSQL (other databases not yet supported)
All contributions are greatly appreciated! This project is in early development and there's plenty of work to do.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.