|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.spif.persistence.TypePersister
Ignore - public for testing only.
A class which knows how to persist a certain type. This
is used from the StorePersister
to handle requests regarding a certain
type.
This class caches discovered information on the fields of the type and the db table used to persist it, to achieve dynamic persistence mapping and high speed.
A typepersister may hold on to other type persisters which are used to persist dependent objects of this persister.
Field Summary | |
protected net.sf.spif.persistence.DependentsPersister |
dependents
The dependent persisters of this type persister |
protected static java.util.logging.Logger |
log
|
protected MatchProperties |
matchProperties
The properties involved in matching at this type |
protected net.sf.spif.persistence.PersistentProperties |
persistentProperties
The persistent properties of this type, or null if it does not have it's own table |
protected net.sf.spif.persistence.PersisterStatements |
statements
The sql statements used by this class, or null if nothing should be persisted for *this* class (but maybe for children) |
Constructor Summary | |
protected |
TypePersister()
Must call initialize after this. |
|
TypePersister(java.lang.Class type,
java.util.Map availableProperties,
net.sf.spif.persistence.DependentPersister parent,
java.sql.Connection connection)
Creates a type persister. |
Method Summary | |
protected void |
addMatchedValues(java.lang.Object object,
java.util.Map values)
Adds values for the matchedProperties to the given map |
void |
bindValues(Id id,
java.lang.Object source,
java.sql.PreparedStatement statement,
java.util.Map unmatchedValues,
boolean update)
|
java.lang.Object |
get(Id id,
java.lang.Object receiver,
java.util.Map leftoverValues,
java.sql.Connection connection)
Reads this object and it dependents from persistent storage. |
MatchProperties |
getMatchProperties()
For testing |
protected net.sf.spif.persistence.DependentPersister |
getParent()
|
protected java.sql.ResultSet |
getRows(Id id,
java.sql.Connection connection)
|
protected java.lang.Class |
getType()
Returns the type this persists |
protected void |
initialize(java.lang.Class type,
java.util.Map availableProperties,
net.sf.spif.persistence.DependentPersister parent,
java.sql.Connection connection)
Does initializing which is obligatory for subclasses as well. |
java.lang.Boolean |
isEmpty()
Returns whether this persister has anything to persist |
protected void |
populateFrom(java.sql.ResultSet row,
java.util.Map leftoverValues,
java.lang.Object object)
Populates an object with setters matching the result set column names. |
protected boolean |
populateFromLeftovers(java.util.Map values,
java.lang.Object object)
Populates an object with setters matching the property names |
void |
put(Id id,
java.lang.Object object,
java.util.Map unmatchedValues,
java.sql.Connection connection)
|
boolean |
remove(Id id,
java.lang.Class type,
java.sql.Connection connection)
|
protected boolean |
rowToObject(Id id,
java.lang.Object receiver,
java.util.Map leftoverValues,
java.sql.ResultSet row)
Creates an instance of the type given by the id and populates setters with matching names in the resultset |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static java.util.logging.Logger log
protected net.sf.spif.persistence.PersisterStatements statements
protected net.sf.spif.persistence.DependentsPersister dependents
protected net.sf.spif.persistence.PersistentProperties persistentProperties
protected MatchProperties matchProperties
Constructor Detail |
protected TypePersister()
public TypePersister(java.lang.Class type, java.util.Map availableProperties, net.sf.spif.persistence.DependentPersister parent, java.sql.Connection connection) throws java.sql.SQLException
type
- the class this persistsavailableProperties
- the unmatched persistent properties of the
owners table, which we may find a match for here, or null if there is
no such propertiesparent
- the parent (owner) of this object, or null if this is a top-level
objectconnection
- a db connection, which the type persister will not hold on to,
or null if we are running tests and should not consult a dbMethod Detail |
protected final void initialize(java.lang.Class type, java.util.Map availableProperties, net.sf.spif.persistence.DependentPersister parent, java.sql.Connection connection) throws java.sql.SQLException
java.sql.SQLException
- if there is no matching tablepublic java.lang.Object get(Id id, java.lang.Object receiver, java.util.Map leftoverValues, java.sql.Connection connection) throws java.sql.SQLException
java.sql.SQLException
public void put(Id id, java.lang.Object object, java.util.Map unmatchedValues, java.sql.Connection connection) throws java.sql.SQLException
java.sql.SQLException
public boolean remove(Id id, java.lang.Class type, java.sql.Connection connection) throws java.sql.SQLException
java.sql.SQLException
public java.lang.Boolean isEmpty()
public MatchProperties getMatchProperties()
protected void addMatchedValues(java.lang.Object object, java.util.Map values)
protected boolean rowToObject(Id id, java.lang.Object receiver, java.util.Map leftoverValues, java.sql.ResultSet row) throws java.sql.SQLException
java.sql.SQLException
protected void populateFrom(java.sql.ResultSet row, java.util.Map leftoverValues, java.lang.Object object) throws java.sql.SQLException
java.sql.SQLException
protected boolean populateFromLeftovers(java.util.Map values, java.lang.Object object) throws java.sql.SQLException
java.sql.SQLException
protected java.sql.ResultSet getRows(Id id, java.sql.Connection connection) throws java.sql.SQLException
java.sql.SQLException
public void bindValues(Id id, java.lang.Object source, java.sql.PreparedStatement statement, java.util.Map unmatchedValues, boolean update) throws java.sql.SQLException
java.sql.SQLException
protected java.lang.Class getType()
protected net.sf.spif.persistence.DependentPersister getParent()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |