Utilities for JDO.
Class | Description |
---|---|
Dao |
Generic DAO implementation based on JDO. |
TaskAdapter |
Empty implementation of TransactionAwareTask . |
TaskExecutor |
Task executor with or without transaction. |
Interface | Description |
---|---|
Task |
Task executed by TaskExecutor . |
TransactionAwareTask |
Sub interface of Task with additional methods for transaction. |
Apache License, Version 2.0
<dependency>
<groupId>com.neovisionaries</groupId>
<artifactId>nv-jdo</artifactId>
<version>1.19</version>
</dependency>
https://github.com/TakahikoKawasaki/nv-jdo.git
http://TakahikoKawasaki.github.io/nv-jdo/
//------------------------------------------------------
// Example of Dao, which is a generic DAO implementation
// based on JDO.
//------------------------------------------------------
// Persistence manager factory.
PersistenceManagerFactory factory = ...;
// Create a DAO with an entity class and the persistence manager factory.
Dao<Customer> dao = new Dao<Customer>(Customer.class, factory);
// Or using a static method.
Dao<Customer> dao = Dao.create(Customer.class, factory);
// Use the DAO.
// (1) Create an entity.
Customer customer = ...;
dao.put(customer);
// (2) Get an entity.
String customerId = ...;
Customer customer = dao.getById(customerId);
// (3) Delete an entity.
dao.delete(customer);
// (4) Delete an entity by ID.
dao.deleteById(customerId);
//------------------------------------------------------
// Example of TaskExecutor.
//------------------------------------------------------
// Persistence manager factory.
PersistenceManagerFactory factory = ...;
// Create a task executor.
TaskExecutor executor = new TaskExecutor(factory);
// Create a task.
Task task = new TaskAdapter() {
@Override
public void beforeTransactionBegin(PersistenceManager manager, Transaction tx) {
tx.setOptimistic(false);
}
@Override
public Object run(PersistenceManager manager) {
......
}
};
// Execute the task.
executor.execute(task, true, 2);
Authlete, Inc.
Takahiko Kawasaki <taka@authlete.com>
Authlete, Inc.
Hideki Ikeda <hide@authlete.com>