db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/jdo ExtentImpl.java PersistenceManagerImpl.java QueryImpl.java TransactionImpl.java
Date Sat, 03 Apr 2004 01:49:00 GMT
brianm      2004/04/02 17:49:00

  Modified:    src/java/org/apache/ojb/jdo ExtentImpl.java
                        PersistenceManagerImpl.java QueryImpl.java
                        TransactionImpl.java
  Log:
  Started unit testing JDO, found some misfeatures already =)
  
  Revision  Changes    Path
  1.4       +5 -5      db-ojb/src/java/org/apache/ojb/jdo/ExtentImpl.java
  
  Index: ExtentImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/ExtentImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExtentImpl.java	3 Apr 2004 00:27:59 -0000	1.3
  +++ ExtentImpl.java	3 Apr 2004 01:48:59 -0000	1.4
  @@ -15,7 +15,7 @@
    * limitations under the License.
    */
   
  -import org.apache.ojb.broker.accesslayer.RsIterator;
  +import org.apache.ojb.broker.accesslayer.OJBIterator;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.query.Criteria;
   import org.apache.ojb.broker.query.Query;
  @@ -31,7 +31,7 @@
    */
   public class ExtentImpl implements Extent
   {
  -	private RsIterator m_iterator;
  +	private OJBIterator m_iterator;
   	private Class m_clazz;
   	private OTMConnection m_conn;
   	private PersistenceManager m_persistenceManager;
  @@ -46,7 +46,7 @@
   		Query q = QueryFactory.newQuery(m_clazz, selectExtent);
   		m_conn = conn;
   		m_persistenceManager = pm;
  -		m_iterator = (RsIterator) m_conn.getIteratorByQuery(q);
  +		m_iterator = (OJBIterator) m_conn.getIteratorByQuery(q);
   	}
   
   	public Iterator iterator()
  @@ -77,9 +77,9 @@
   
   	public void close(Iterator iterator)
   	{
  -		if (iterator instanceof RsIterator)
  +		if (iterator instanceof OJBIterator)
           {
  -			((RsIterator) iterator).releaseDbResources();
  +			((OJBIterator)iterator).releaseDbResources();
           }
   	}
   }
  
  
  
  1.5       +10 -2     db-ojb/src/java/org/apache/ojb/jdo/PersistenceManagerImpl.java
  
  Index: PersistenceManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/PersistenceManagerImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PersistenceManagerImpl.java	3 Apr 2004 00:27:59 -0000	1.4
  +++ PersistenceManagerImpl.java	3 Apr 2004 01:48:59 -0000	1.5
  @@ -44,7 +44,7 @@
       private String m_password;
       private String m_alias;
       private Object m_usersObject;
  -    private Transaction m_tx;
  +    private TransactionImpl m_tx;
       private StateManager m_stateManager;
   
   
  @@ -90,7 +90,7 @@
           {
               throw new JDOFatalUserException(generateIsClosedErrorMessage("currentTransaction()"));
           }
  -        if (m_tx == null)
  +        if (m_tx == null || m_tx.isExpired())
           {
               m_tx = new TransactionImpl(this, m_kit.getTransaction(m_conn));
           }
  @@ -381,8 +381,16 @@
           return query;
       }
   
  +    /**
  +     * @todo figure out how to implement, may have to query all and filter objects
  +     *
  +     * @param aClass top level class
  +     * @param b include subclasses
  +     * @return
  +     */
       public Extent getExtent(Class aClass, boolean b)
       {
  +        if (!b) throw new UnsupportedOperationException("Not yet implemented!");
           if (isClosed())
           {
               throw new JDOFatalUserException(generateIsClosedErrorMessage("getExtent(Class,
boolean)"));
  
  
  
  1.4       +5 -2      db-ojb/src/java/org/apache/ojb/jdo/QueryImpl.java
  
  Index: QueryImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/QueryImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- QueryImpl.java	3 Apr 2004 00:27:59 -0000	1.3
  +++ QueryImpl.java	3 Apr 2004 01:48:59 -0000	1.4
  @@ -47,7 +47,7 @@
           this.m_pm = pm;
           this.m_conn = conn;
           this.m_criteria = new Criteria();
  -        this.m_candidates = new HashSet();
  +        this.m_candidates = null;
       }
   
   	public void setClass(Class aClass)
  @@ -57,6 +57,7 @@
   
   	public void setCandidates(Extent extent)
   	{
  +        if (m_candidates == null) m_candidates = new HashSet();
           Iterator itty = extent.iterator();
           while (itty.hasNext())
           {
  @@ -66,6 +67,7 @@
   
   	public void setCandidates(Collection collection)
   	{
  +        if (m_candidates == null) m_candidates = new HashSet();
           this.m_candidates.addAll(collection);
   	}
   
  @@ -113,7 +115,8 @@
   	{
           QueryByCriteria query = QueryFactory.newQuery(m_searchClass, this.m_criteria);
   		Collection results =  (Collection) m_conn.getCollectionByQuery(query);
  -        return CollectionUtils.intersection(results, this.m_candidates);
  +        if (m_candidates != null) return CollectionUtils.intersection(results, this.m_candidates);
  +        else return results;
   	}
   
   	public Object execute(Object o)
  
  
  
  1.3       +8 -0      db-ojb/src/java/org/apache/ojb/jdo/TransactionImpl.java
  
  Index: TransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/TransactionImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TransactionImpl.java	11 Mar 2004 18:16:16 -0000	1.2
  +++ TransactionImpl.java	3 Apr 2004 01:48:59 -0000	1.3
  @@ -27,6 +27,7 @@
   {
   	private PersistenceManager m_persistenceManager;
   	private org.apache.ojb.otm.core.Transaction m_tx;
  +    private boolean m_isExpired = false;
   
   	public TransactionImpl(PersistenceManager persistenceManager, org.apache.ojb.otm.core.Transaction
tx)
   	{
  @@ -34,6 +35,11 @@
   		m_tx = tx;
   	}
   
  +    boolean isExpired()
  +    {
  +        return this.m_isExpired;
  +    }
  +
   	public void begin()
   	{
   		m_tx.begin();
  @@ -42,11 +48,13 @@
   	public void commit()
   	{
   		m_tx.commit();
  +        m_isExpired = true;
   	}
   
   	public void rollback()
   	{
   		m_tx.rollback();
  +        m_isExpired = true;
   	}
   
   	public boolean isActive()
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message