|
SolarMetric Kodo JDO 2.5.8 generated on January 11 2004 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.solarmetric.kodo.runtime.objectprovider.CustomResultObjectProviderImpl
|
+--com.solarmetric.kodo.impl.jdbc.runtime.CustomResultSetResultObjectProvider
Abstract extension of CustomResultObjectProviderImpl
that populates a StateManagerImpl object given a
Map of FieldMetaData
objects to Object values, created by the
abstract CustomResultObjectProviderImpl.getFieldValues(java.lang.Object, com.solarmetric.kodo.meta.ClassMetaData, boolean) method.
Extensions of this class can be used to load data via non-SQL means such as via stored procedures. For example:
import java.util.*;
import com.solarmetric.kodo.runtime.*;
import com.solarmetric.kodo.impl.jdbc.runtime.*;
...
PersistenceManagerImpl pm = (PersistenceManagerImpl) pman;
final JDBCStoreManager store =
(JDBCStoreManager) pm.getStoreManager ();
final Connection conn = store.getConnection ();
Statement st = conn.createStatement ();
ResultSet rs = st.executeQuery
("SELECT ID, FIRSTNAME, LASTNAME FROM PERSON");
CustomResultSetResultObjectProvider rop =
new CustomResultSetResultObjectProvider (pm)
{
public Class getType (Object input)
{
return Person.class;
}
public Map getFieldValues (Object input, ClassMetaData meta,
boolean pkOnly)
throws SQLException
{
ResultSet rs = (ResultSet) input;
Map map = new HashMap ();
map.put (meta.getField ("firstName"), rs.getString (2));
map.put (meta.getField ("lastName"), rs.getString (3));
return map;
}
public long getDatastoreId (Object input, ClassMetaData meta)
throws SQLException
{
ResultSet rs = (ResultSet) input;
return rs.getLong (1);
}
public Object getOptimisticLockVersion (Object input,
ClassMetaData meta)
throws SQLException
{
return null;
}
public void free (Object input)
throws Exception
{
super.free (input);
store.releaseConnection (conn);
}
};
List l = rop.getResultList (rs);
for (Iterator iter = l.iterator (); iter.hasNext (); )
{
System.out.println ("person: " + iter.next ());
}
Note that the objects remain valid after the connection used to
obtain them is closed, so the connection must not be released
until after the result list has been fully loaded. This can be
done in the free(java.lang.Object) method. The default free
implementation closes the result set and its owning statement, but
does not close or release the owning connection.
ResultList objects do not necessarily load in data all
at once. Instead, they lazily load rows from the result set as
necessary, if the result set is
TYPE_SCROLL_INSENSITIVE.
This class automatically closes the ResultSet and its
Statement when the result set is fully processed. To
change this behavior, override free(java.lang.Object).
| Inner classes inherited from class com.solarmetric.kodo.runtime.objectprovider.CustomResultObjectProvider |
CustomResultObjectProvider.ResultObjectProviderAdapter, CustomResultObjectProvider.ROPInfo |
| Fields inherited from class com.solarmetric.kodo.runtime.objectprovider.CustomResultObjectProviderImpl |
pm |
| Constructor Summary | |
CustomResultSetResultObjectProvider(PersistenceManagerImpl pm)
Create a new ResultSetResultObjectProvider for loading objects of into pm. |
|
| Method Summary | |
boolean |
advance(Object o)
Invokes ResultSet.next(). |
void |
free(Object o)
Closes the result set and its owning statement. |
ResultList |
getResultList(ResultSet rs)
Retrieve a ResultList (implementation of List)
that is populated by objects created from rs. |
boolean |
open(Object o)
Invokes ResultSet.next(). |
| Methods inherited from class com.solarmetric.kodo.runtime.objectprovider.CustomResultObjectProviderImpl |
getDatastoreId, getFieldValues, getObjectId, getOptimisticLockVersion, getPersistenceManager, getROPInfo, initialize, load |
| Methods inherited from class java.lang.Object |
|
| Methods inherited from interface com.solarmetric.kodo.runtime.objectprovider.CustomResultObjectProvider |
getType |
| Constructor Detail |
public CustomResultSetResultObjectProvider(PersistenceManagerImpl pm)
pm.| Method Detail |
public ResultList getResultList(ResultSet rs)
throws SQLException
ResultList (implementation of List)
that is populated by objects created from rs.
public boolean open(Object o)
throws Exception
ResultSet.next().
public boolean advance(Object o)
throws Exception
ResultSet.next().
public void free(Object o)
throws Exception
|
SolarMetric Kodo JDO 2.5.8 generated on January 11 2004 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||