User managedUser = manager.find(User.class,1L); user.setFirstname("DuyHai"); manager.update(user);
// Simple deletion User managedUser = manager.find(User.class,1L); manager.delete(managedUser); // Direct deletion without read-before-write manager.deleteById(User.class,1L);
// Read data from Cassandra User managedUser = manager.find(User.class,1L);
// No data read from Cassandra User managedUser = manager.getProxy(User.class,1L); managedUser.setAge(30); // Direct update, no read from Cassandra has been done manager.update(managedUser);
// Read data from Cassandra User managedUser = manager.find(User.class,1L); ... // Perform some logic // Reload data from Cassandra into the managed entity manager.refresh(managedUser);
// Create a proxy User managedUser = manager.getProxy(User.class,1L); ... // Perform some logic // Initialize all fields not yet loaded into the managed entity, including counter fields manager.initialize(managedUser);
// Create proxy User managedUser = manager.getProxy(User.class,1L); ... // Perform some logic // Removing proxy before passing it to client via serialization User transientUser = manager.removeProxy(managedUser);
Session session = manager.getNativeSession(); ... // Issue simple CQL3 queries session.execute("UPDATE users SET age=:age WHERE id=:id",30,10);
// Serialize an object to JSON using the registered or default object mapper String json = manager.serializeToJSON(myModel); ... // Deserialize a JSON string into an object the registered or default object mapper MyModel myModel = manager.deserializeFromJSON(json);
// Create proxy User userProxy = manager.getProxy(User.class,1L); ... // Perform some logic ... // Load all other lazy fields manager.initialize(userProxy);
@see Persistence Manager operations
PersistenceManager
is the primary interface for JDO-aware application components. It is the factory for Query
and Transaction
instances, and contains methods to manage the life cycle of PersistenceCapable
instances. A PersistenceManager
is obtained from the {@link PersistenceManagerFactory}(recommended) or by construction.
@version 2.1
PersistenceManager
interface defines the API to be implemented to support persisting configuration data. This interface may be implemented by bundles, which support storing configuration data in different locations. The Apache Felix Configuration Admin Service bundles provides an implementation of this interface using the platform filesystem to store configuration data.
Implementations of this interface must support loading and storing java.util.Dictionary
objects as defined in section 104.4.2, Configuration Properties, of the Configuration Admin Service Specification Version 1.2.
To make implementations of this interface available to the Configuration Admin Service they must be registered as service for this interface. The Configuration Admin Service will consider all registered services plus the default platform file system based implementation to load configuration data. To store new configuration data, the persistence manager service with the highest rank value - the service.ranking
service property - is used. If no pesistence manager service has been registered, the platfrom file system based implementation is used.
Each workspace of a Jackrabbit content repository uses separate persistence manager to store the content in that workspace. Also the Jackrabbit version handler uses a separate persistence manager. The persistence managers in use are configured in the Jackrabbit XML configuration files. The configured persistence managers are instantiated and initialized using the JavaBeans conventions.
The life cycle of a persistence manager instance contains four phases:
Each workspace of a Jackrabbit content repository uses separate persistence manager to store the content in that workspace. Also the Jackrabbit version handler uses a separate persistence manager. The persistence managers in use are configured in the Jackrabbit XML configuration files. The configured persistence managers are instantiated and initialized using the JavaBeans conventions.
The life cycle of a persistence manager instance contains four phases:
Instances of this class can be created by using a {@link PersistenceManagerBuilder}created using the {@link PersistenceManagerBuilder#newBuilder()} method.
Use a {@link PersistenceSession} via {@link #createSession()} to perform loads, inserts, updates and deletes.
Siena
. PersistenceManagerFactory
will instanciate implementations of this interface when required. Most of the methods of this interface will be called indirectly from the Model
class.
@author gimenete
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|