Enterprise Java Bean Support
PikaORM provides a custom enterprise bean implementation through EnterprisePikaBean that
combines ORM functionality with validation and lifecycle management. Unlike traditional heavy EJBs, this
is a lightweight, ORM-focused bean system.
Key Features
๐กAuto persistence tracking
โ
Built-in validation
๐Change tracking
๐Relationship loading
- Automatic persistence tracking โ Beans know if they're persisted or new.
- Built-in validation system with field-level error handling.
- Change tracking โ Only updates modified fields.
- Relationship loading โ Built-in support for 1:N and N:M relationships.
Basic Usage
public class User extends EnterprisePikaBean {
private String name;
private String email;
private Integer age;
@Override
protected void validation() {
if (name == null || name.trim().isEmpty()) {
addError("name", "Name is required");
}
if (email == null || !email.contains("@")) {
addError("email", "Valid email is required");
}
}
}
CRUD Operations
Because the bean inherits from EnterprisePikaBean, it handles its own database state.
// Create new record
User user = new User();
user.setName("John Doe");
user.setEmail("john@example.com");
if (user.validate()) {
Long id = user.insert(); // Returns generated ID
}
// Update existing record
user.setName("Jane Doe");
user.save(); // Automatically calls update() since it tracks its persisted state
// Delete record
user.delete();
Loading Relationships
// Load one-to-many relationship
PikaManyQuery<Order> orders = user.loadMany(Order.class);
// Load many-to-many through join table
PikaManyThroughQuery<UserRole, Role> roles =
user.loadManyThrough(UserRole.class, Role.class);
// Load single related entity
Company company = user.load(Company.class);
EJB Context: Traditional EJBs require complex container dependencies. PikaORM's implementation is a Simple POJO approach that works in any Java environment โ directly mapped to your database.
Simple, honest, no magic. That's the PikaORM way.โ PikaORM docs, end of the road ๐