com.evermind.server.ejb
Interface FieldPersistenceManager
- public interface FieldPersistenceManager
A FieldPersistenceManager handles persistence of one in a CMP entity.
It is used when providing custom persistence algorithms, an example could
be an int value stored as a hex string in the database.
Here is a sample config for using a FieldPersistenceManager in orion-ejb-jar.xml:
<cmp-field-mapping name="aField" persistence-name="aField">
<field-persistence-manager class="com.evermind.server.ejb.StringFieldPersistenceManager" />
</cmp-field-mapping>
The configuration can also define extra properties for advanced managers.
The default properties that are always supplied are:
name - the name of the CMP field.
persistenceName - the specified persistence-name.
persistenceType - the specified persistence-type if any.
Combo field managers (storing to 2+ database table fields) would need to use additional properties.
|
Method Summary |
java.lang.Object |
get(java.sql.ResultSet set)
Performs a 'read' operation to retrieve the handled field.
|
java.util.Map |
getColumns()
Requests the database columns used by this manager. |
java.util.Properties |
getProperties()
Retrieves the properties, possibly updated by the manager (cleaned up, altered). |
void |
init(java.util.Properties properties)
Initializes the manager with the supplied properties. |
void |
set(java.sql.PreparedStatement statement,
int columnID,
java.lang.Object value)
Performs a 'write' operation to persist the handled field.
|
init
public void init(java.util.Properties properties)
throws java.lang.InstantiationException
- Initializes the manager with the supplied properties.
get
public java.lang.Object get(java.sql.ResultSet set)
throws java.sql.SQLException
- Performs a 'read' operation to retrieve the handled field.
The name to use for ResultSet operations is supplied in the properties in init(...).
High performance managers may also provide a getPrimitive(ResultSet set) for primitive types.
set
public void set(java.sql.PreparedStatement statement,
int columnID,
java.lang.Object value)
throws java.sql.SQLException
- Performs a 'write' operation to persist the handled field.
The columnID is the first ID used by the (possible combo-field) handler.
The value is the field's value, converted to Object form if needed. (int -> Integer, etc).
A special case is if the handler class has defined a public void set(PreparedStatement statement, int columnID, value)
and the field is of a primitive type. In that case that method will be called instead. This
is purely an optimization for advanced handlers.
getColumns
public java.util.Map getColumns()
- Requests the database columns used by this manager. Returns an empty Map if no columns are used and a set of persistence-name -> persistence-type mappings otherwise.
getProperties
public java.util.Properties getProperties()
- Retrieves the properties, possibly updated by the manager (cleaned up, altered).