Hi Allen,I excerpted parts of the code I uploaded to the JIRA issue so we could discuss some salient parts. The full upload is at http:// opensource.atlassian.com/projects/roller/browse/ROL-977
I thought that the 82K would make for an awkward email discussion if I included the whole thing.
On Aug 16, 2006, at 7:38 PM, Allen Gilliland wrote:
comments inline ... Craig L Russell wrote:Hi,Here's what I propose as a starting point for the query interface between Datamapper Managers and Datamapper Persistence.This already confuses me. Exactly how much stuff are we adding?
Here's most of it: svn status sandbox/jdobackend/ ? sandbox/jdobackend/lib/jdom.jar ? sandbox/jdobackend/lib/jdo2-api-2.0.jarA sandbox/jdobackend/src/org/apache/roller/business/jdo/ JDOPersistenceStrategy.java A sandbox/jdobackend/src/org/apache/roller/business/jdo/ JDOQueryImpl.java
A sandbox/jdobackend/src/org/apache/roller/business/datamapperA sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperPlanetManagerImpl.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperPingTargetManagerImpl.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperRollerImpl.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperBookmarkManagerImpl.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperAutoPingManagerImpl.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperQuery.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperPersistenceStrategy.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperPropertiesManagerImpl.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperReferrerManagerImpl.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperUserManagerImpl.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperWeblogManagerImpl.java A sandbox/jdobackend/src/org/apache/roller/business/datamapper/ DatamapperPingQueueManagerImpl.java
Plus a JDO implementation of the Roller.
It was my understanding that you were basically planning to provide some kind of generic implementation of all of the XXXManager interfaces which would use the Datamapper.
Right. See above.
So presumably someone doing a backend implementation only needs to extend the generic manager implementations to fill out extra methods, plus do a Datamapper implementation.
Actually, just a Roller and DatamapperPersistenceStrategy implementation, including writing the named queries (about 100 as I recall).
Is that right? Also, is the Datamapper only for queries? or are you planning for this to include all persistence operations including write operations?
It includes everything. Here's what I have so far...
public interface DatamapperPersistenceStrategy {
/**
* Flush changes to the datastore, commit transaction, release pm.
* @throws org.apache.roller.RollerException on any error
*/
void flush()
throws RollerException;
/**
* Release database session, rolls back any uncommitted changes.
*/
void release();
/**
* Store object in the database. Start a transaction if no
* transaction in progress.
* @param obj the object to persist
* @return the object persisted
* @throws org.apache.roller.RollerException on any error
*/
PersistentObject store(PersistentObject obj)
throws RollerException;
/**
* Remove object from persistence storage. Start a transaction
if no
* transaction in progress.
* @param clazz the class of object to remove
* @param id the id of the object to remove
* @throws RollerException on any error deleting object
*/
public void remove(Class clazz, String id)
throws RollerException;
/**
* Remove object from persistence storage. Start a transaction
if no
* transaction in progress.
* @param po the persistent object to remove
* @throws org.apache.roller.RollerException on any error
*/
public void remove(PersistentObject po)
throws RollerException;
/**
* Remove objects from persistence storage. Start a transaction
if no
* transaction in progress.
* @param pos the persistent objects to remove
* @throws org.apache.roller.RollerException on any error
*/
public void removeAll(Collection pos)
throws RollerException;
/**
* Remove objects from persistence storage. Start a transaction
if no
* transaction in progress.
* @param clazz the persistent from which to remove all objects
* @throws org.apache.roller.RollerException on any error
*/
public void removeAll(Class clazz)
throws RollerException;
/**
* Retrieve object, no transaction needed.
* @param clazz the class of object to retrieve
* @param id the id of the object to retrieve
* @return the object retrieved
* @throws RollerException on any error retrieving object
*/
public PersistentObject load(Class clazz, String id)
throws RollerException;
/**
* Create query.
* @param clazz the class of instances to find
* @param queryName the name of the query
* @throws org.apache.roller.RollerException on any error
*/
public DatamapperQuery newQuery(Class clazz, String queryName)
throws RollerException;
}
Hope this gives the detail you need...
Craig
There are enough differences between JDO, JPA, and Hibernate that I found it really awkward to define a set of methods on PersistenceStrategy that covered the functionality. In particular, there are two methods in JPA that both execute the query and determine the result shape, and parameters are passed one by one. In JDO, there is an API that determines the result shape and one method to execute the query, passing parameter values. It's trivial to encapsulate these differences in a Query instance. I've included the Query API below for discussion, along with calling sequence from Mapper.Craig public class DatamapperPersistenceStrategy { ... /** * Create query. * @param clazz the class of instances to find * @param queryName the name of the query * @throws org.apache.roller.RollerException on any error */ public DatamapperQuery newQuery(Class clazz, String queryName) throws RollerException; } public class DatamapperUserManagerImpl { ...public WebsiteData getWebsiteByHandle(String handle, Boolean enabled)throws RollerException { // XXX cache websites by handle? return (WebsiteData)strategy.newQuery(WebsiteData.class, "getByHandle&&Enabled") .execute(new Object[]{handle, enabled}); }both of those make sense to me.public interface DatamapperQuery { /** Execute the query with no parameters. * @return the results of the query */ Object execute(); /** Execute the query with one parameter. * @param param the parameter * @return the results of the query */ Object execute(Object param); /** Execute the query with parameters. * @param params the parameters * @return the results of the query */ Object execute(Object[] params); /** Remove instances selected by the query with no parameters. * @return the results of the query */ void removeAll(); /** Remove instances selected by the query with one parameter. * @param param the parameter * @return the results of the query */ void removeAll(Object param); /** Remove instances selected by the query with parameters. * @param params the parameters * @return the results of the query */ void removeAll(Object[] params); /** Set the result to be a single instance (not a List). * @result the instance on which this method is called */ DatamapperQuery setUnique(); /** Set the types of the parameters. This is only needed if the * parameter types are temporal types, e.g. Date, Time, Calendar. * @param the types of the parameters in corresponding positions. * @result the instance on which this method is called */ DatamapperQuery setTypes(Object[] types); /** Set the range of results for this query. * @fromIncl the beginning row number * @toExcl the ending row number * @return the instance on which this method is called */ DatamapperQuery setRange(long fromIncl, long toExcl); }this seems like it could be a very complex undertaking to me and doesn't it seem like we would be reinventing the wheel a bit? Hibernate already provides a very elaborate Query interface which you are basically proposing we try and duplicate.in any case, i don't understand the removeAll() methods, how are they supposed to work?-- AllenCraig Russell [EMAIL PROTECTED] http://db.apache.org/jdo
Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp!
smime.p7s
Description: S/MIME cryptographic signature
