db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r538361 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java
Date Tue, 15 May 2007 22:59:22 GMT
Author: arminw
Date: Tue May 15 15:59:22 2007
New Revision: 538361

URL: http://svn.apache.org/viewvc?view=rev&rev=538361
Log:
fix memory leak

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java?view=diff&rev=538361&r1=538360&r2=538361
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java
Tue May 15 15:59:22 2007
@@ -18,6 +18,7 @@
 import java.util.Collection;
 import java.util.Enumeration;
 import java.util.Map;
+import java.lang.ref.WeakReference;
 
 import org.apache.commons.collections.map.ReferenceIdentityMap;
 import org.apache.ojb.broker.metadata.ClassDescriptor;
@@ -620,10 +621,15 @@
      */
     public static class SqlForClass
     {
+        /*
+         TODO: Currently we have to take care of references to metadata classes. These classes
+         may be set free, so it's not allowed to use hard references to metadata class instances,
because
+         the object with the reference may be cached. Rework this in next major version.
+        */
         private SqlStatement deleteSql;
         private SqlStatement insertSql;
         private SqlStatement updateSql;
-        private SelectStatement selectByPKSql;
+        private WeakReference selectByPKSql;
         private SqlStatement selectExists;
 
         public SqlStatement getDeleteSql()
@@ -658,12 +664,12 @@
 
         public SelectStatement getSelectByPKSql()
         {
-            return selectByPKSql;
+            return selectByPKSql != null ? (SelectStatement) selectByPKSql.get() : null;
         }
 
         public void setSelectByPKSql(SelectStatement selectByPKSql)
         {
-            this.selectByPKSql = selectByPKSql;
+            this.selectByPKSql = new WeakReference(selectByPKSql);
         }
 
         public SqlStatement getSelectExists()



---------------------------------------------------------------------
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