================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/expressions/ExpressionBuilder.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.12 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.12 Fri Nov 3 14:41:03 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/expressions/ExpressionBuilder.java Sun Nov 5 13:07:28 2006 *************** *** 257,263 **** if (this.queryClass != null) { Expression criteria = null; ! setSession(normalizer.getSession()); // The descriptor must be defined at this point. if (getDescriptor() == null) { throw QueryException.noExpressionBuilderFound(this); --- 257,263 ---- if (this.queryClass != null) { Expression criteria = null; ! setSession(normalizer.getSession().getRootSession(null)); // The descriptor must be defined at this point. if (getDescriptor() == null) { throw QueryException.noExpressionBuilderFound(this); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ObjectLevelReadQuery.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.24 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.24 Fri Nov 3 14:41:43 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ObjectLevelReadQuery.java Sun Nov 5 13:07:28 2006 *************** *** 355,361 **** ObjectExpression objectExpression = (ObjectExpression)joinedExpressions.get(index); // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(getSession()); objectExpression.getBuilder().setQueryClass(getReferenceClass()); ClassDescriptor descriptor = objectExpression.getMapping().getReferenceDescriptor(); fields.addAll(descriptor.getFields()); --- 355,361 ---- ObjectExpression objectExpression = (ObjectExpression)joinedExpressions.get(index); // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(getSession().getRootSession(null)); objectExpression.getBuilder().setQueryClass(getReferenceClass()); ClassDescriptor descriptor = objectExpression.getMapping().getReferenceDescriptor(); fields.addAll(descriptor.getFields()); *************** *** 990,996 **** Expression expression = (Expression)fetchGroupAttrExps.get(index); // Expression may not have been initialized. ! expression.getBuilder().setSession(getSession()); expression.getBuilder().setQueryClass(getReferenceClass()); Helper.addAllToVector(fields, expression.getFields()); } --- 990,996 ---- Expression expression = (Expression)fetchGroupAttrExps.get(index); // Expression may not have been initialized. ! expression.getBuilder().setSession(getSession().getRootSession(null)); expression.getBuilder().setQueryClass(getReferenceClass()); Helper.addAllToVector(fields, expression.getFields()); } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ReadAllQuery.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.13 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.13 Fri Nov 3 14:41:44 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ReadAllQuery.java Sun Nov 5 13:07:29 2006 *************** *** 206,212 **** if (getSelectionCriteria() != null) { selectionCriteriaClone = (Expression)getSelectionCriteria().clone(); ! selectionCriteriaClone.getBuilder().setSession(unitOfWork); selectionCriteriaClone.getBuilder().setQueryClass(getReferenceClass()); } cp = getContainerPolicy(); --- 206,212 ---- if (getSelectionCriteria() != null) { selectionCriteriaClone = (Expression)getSelectionCriteria().clone(); ! selectionCriteriaClone.getBuilder().setSession(unitOfWork.getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(getReferenceClass()); } cp = getContainerPolicy(); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ReadObjectQuery.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.13 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.13 Fri Nov 3 14:41:44 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ReadObjectQuery.java Sun Nov 5 13:07:29 2006 *************** *** 300,306 **** Expression selectionCriteriaClone = null; if ((getSelectionCriteria() != null) && (getSelectionKey() == null) && (getSelectionObject() == null)) { selectionCriteriaClone = (Expression)getSelectionCriteria().clone(); ! selectionCriteriaClone.getBuilder().setSession(unitOfWork); selectionCriteriaClone.getBuilder().setQueryClass(getReferenceClass()); } --- 300,306 ---- Expression selectionCriteriaClone = null; if ((getSelectionCriteria() != null) && (getSelectionKey() == null) && (getSelectionObject() == null)) { selectionCriteriaClone = (Expression)getSelectionCriteria().clone(); ! selectionCriteriaClone.getBuilder().setSession(unitOfWork.getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(getReferenceClass()); } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/descriptors/ObjectBuilder.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.29 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.29 Fri Nov 3 14:43:44 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/descriptors/ObjectBuilder.java Sun Nov 5 13:07:29 2006 *************** *** 1442,1451 **** //put the curent session onthe expression builder for use later store current session incase //it is required at a later stage AbstractSession oldSession = expression.getBuilder().getSession(); ! expression.getBuilder().setSession(session); // Get all the field & values from expression. boolean isValid = expression.extractPrimaryKeyValues(requiresExactMatch, getDescriptor(), primaryKeyRow, translationRow); - expression.getBuilder().setSession(oldSession); if (requiresExactMatch && (!isValid)) { return null; } --- 1442,1450 ---- //put the curent session onthe expression builder for use later store current session incase //it is required at a later stage AbstractSession oldSession = expression.getBuilder().getSession(); ! expression.getBuilder().setSession(session.getRootSession(null)); // Get all the field & values from expression. boolean isValid = expression.extractPrimaryKeyValues(requiresExactMatch, getDescriptor(), primaryKeyRow, translationRow); if (requiresExactMatch && (!isValid)) { return null; } *************** *** 1540,1549 **** //put the curent session onthe expression builder for use later store current session incase //it is required at a later stage AbstractSession oldSession = expression.getBuilder().getSession(); ! expression.getBuilder().setSession(session); // Get all the field & values from expression boolean isValid = expression.extractPrimaryKeyValues(true, getDescriptor(), primaryKeyRow, translationRow); ! expression.getBuilder().setSession(session); if (!isValid) { return null; } --- 1539,1548 ---- //put the curent session onthe expression builder for use later store current session incase //it is required at a later stage AbstractSession oldSession = expression.getBuilder().getSession(); ! expression.getBuilder().setSession(session.getRootSession(null)); // Get all the field & values from expression boolean isValid = expression.extractPrimaryKeyValues(true, getDescriptor(), primaryKeyRow, translationRow); ! expression.getBuilder().setSession(session.getRootSession(null)); if (!isValid) { return null; } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/expressions/CompoundExpression.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.7 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.7 Fri Nov 3 14:43:48 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/expressions/CompoundExpression.java Sun Nov 5 13:07:29 2006 *************** *** 164,170 **** //let's make sure a session is available in the case of a parallel expression ExpressionBuilder builder = getFirstChild().getBuilder(); if (builder != null){ ! builder.setSession(normalizer.getSession()); } setFirstChild(getFirstChild().normalize(normalizer)); } --- 164,170 ---- //let's make sure a session is available in the case of a parallel expression ExpressionBuilder builder = getFirstChild().getBuilder(); if (builder != null){ ! builder.setSession(normalizer.getSession().getRootSession(null)); } setFirstChild(getFirstChild().normalize(normalizer)); } *************** *** 172,178 **** //let's make sure a session is available in the case of a parallel expression ExpressionBuilder builder = getSecondChild().getBuilder(); if (builder != null){ ! builder.setSession(normalizer.getSession()); } setSecondChild(getSecondChild().normalize(normalizer)); } --- 172,178 ---- //let's make sure a session is available in the case of a parallel expression ExpressionBuilder builder = getSecondChild().getBuilder(); if (builder != null){ ! builder.setSession(normalizer.getSession().getRootSession(null)); } setSecondChild(getSecondChild().normalize(normalizer)); } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/expressions/SQLSelectStatement.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.21 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.21 Fri Nov 3 14:43:48 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/expressions/SQLSelectStatement.java Sun Nov 5 13:07:29 2006 *************** *** 1091,1097 **** setWhereClause(null); } ! builder.setSession(session); // Some queries are not on objects but for data, thus no descriptor. if (!builder.doesNotRepresentAnObjectInTheQuery()) { --- 1091,1097 ---- setWhereClause(null); } ! builder.setSession(session.getRootSession(null)); // Some queries are not on objects but for data, thus no descriptor. if (!builder.doesNotRepresentAnObjectInTheQuery()) { ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/identitymaps/IdentityMapManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.14 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.14 Fri Nov 3 14:43:48 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/identitymaps/IdentityMapManager.java Sun Nov 5 13:07:29 2006 *************** *** 369,375 **** // Only clone if required. if ((selectionCriteria != null) && (selectionCriteriaClone.getBuilder().getSession() == null)) { selectionCriteriaClone = (Expression)selectionCriteria.clone(); ! selectionCriteriaClone.getBuilder().setSession(getSession()); selectionCriteriaClone.getBuilder().setQueryClass(theClass); } objects = new Vector(); --- 369,375 ---- // Only clone if required. if ((selectionCriteria != null) && (selectionCriteriaClone.getBuilder().getSession() == null)) { selectionCriteriaClone = (Expression)selectionCriteria.clone(); ! selectionCriteriaClone.getBuilder().setSession(getSession().getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(theClass); } objects = new Vector(); *************** *** 555,561 **** // Only clone if required. if ((selectionCriteria != null) && (selectionCriteriaClone.getBuilder().getSession() == null)) { selectionCriteriaClone = (Expression)selectionCriteria.clone(); ! selectionCriteriaClone.getBuilder().setSession(getSession()); selectionCriteriaClone.getBuilder().setQueryClass(theClass); } IdentityMap map = getIdentityMap(descriptor); --- 555,561 ---- // Only clone if required. if ((selectionCriteria != null) && (selectionCriteriaClone.getBuilder().getSession() == null)) { selectionCriteriaClone = (Expression)selectionCriteria.clone(); ! selectionCriteriaClone.getBuilder().setSession(getSession().getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(theClass); } IdentityMap map = getIdentityMap(descriptor); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/ExpressionQueryMechanism.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.32 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.32 Sun Nov 5 13:03:43 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/ExpressionQueryMechanism.java Sun Nov 5 13:07:29 2006 *************** *** 589,595 **** updateAllStatement.setWhereClause(getSelectionCriteria()); if(updateAllStatement.getWhereClause() != null) { updateAllStatement.setWhereClause((Expression)updateAllStatement.getWhereClause().clone()); ! updateAllStatement.getWhereClause().getBuilder().setSession(getSession()); updateAllStatement.getWhereClause().getBuilder().setQueryClass(getQuery().getReferenceClass()); } } --- 589,595 ---- updateAllStatement.setWhereClause(getSelectionCriteria()); if(updateAllStatement.getWhereClause() != null) { updateAllStatement.setWhereClause((Expression)updateAllStatement.getWhereClause().clone()); ! updateAllStatement.getWhereClause().getBuilder().setSession(getSession().getRootSession(null)); updateAllStatement.getWhereClause().getBuilder().setQueryClass(getQuery().getReferenceClass()); } } *************** *** 1526,1532 **** if(field == null) { DataExpression fieldExpressionClone = (DataExpression)fieldExpression.clone(); fieldExpressionClone.getBuilder().setQueryClass(getQuery().getReferenceClass()); ! fieldExpressionClone.getBuilder().setSession(getSession()); field = fieldExpressionClone.getField(); if(field == null) { throw QueryException.updateAllQueryAddUpdateDoesNotDefineField(getDescriptor(), getQuery(), fieldExpression.toString()); --- 1526,1532 ---- if(field == null) { DataExpression fieldExpressionClone = (DataExpression)fieldExpression.clone(); fieldExpressionClone.getBuilder().setQueryClass(getQuery().getReferenceClass()); ! fieldExpressionClone.getBuilder().setSession(getSession().getRootSession(null)); field = fieldExpressionClone.getField(); if(field == null) { throw QueryException.updateAllQueryAddUpdateDoesNotDefineField(getDescriptor(), getQuery(), fieldExpression.toString()); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/JoinedAttributeManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.5 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.5 Fri Nov 3 14:43:48 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/JoinedAttributeManager.java Sun Nov 5 13:07:29 2006 *************** *** 198,204 **** ObjectExpression objectExpression = (ObjectExpression)joinedExpressions.get(index); // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(session); objectExpression.getBuilder().setQueryClass(getDescriptor().getJavaClass()); // PERF: Cache join attribute names. --- 198,204 ---- ObjectExpression objectExpression = (ObjectExpression)joinedExpressions.get(index); // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(session.getRootSession(null)); objectExpression.getBuilder().setQueryClass(getDescriptor().getJavaClass()); // PERF: Cache join attribute names. *************** *** 537,543 **** QueryKeyExpression objectExpression = (QueryKeyExpression)expression; // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(session); if (objectExpression.getBuilder().getQueryClass() == null){ objectExpression.getBuilder().setQueryClass(this.descriptor.getJavaClass()); } --- 537,543 ---- QueryKeyExpression objectExpression = (QueryKeyExpression)expression; // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(session.getRootSession(null)); if (objectExpression.getBuilder().getQueryClass() == null){ objectExpression.getBuilder().setQueryClass(this.descriptor.getJavaClass()); } *************** *** 682,688 **** ObjectExpression joinedAttribute = (ObjectExpression)expression; // Expression may not have been initialized. ! joinedAttribute.getBuilder().setSession(session); joinedAttribute.getBuilder().setQueryClass(getDescriptor().getJavaClass()); ClassDescriptor nestedDescriptor = null;// joinedAttribute.getDescriptor(); --- 682,688 ---- ObjectExpression joinedAttribute = (ObjectExpression)expression; // Expression may not have been initialized. ! joinedAttribute.getBuilder().setSession(session.getRootSession(null)); joinedAttribute.getBuilder().setQueryClass(getDescriptor().getJavaClass()); ClassDescriptor nestedDescriptor = null;// joinedAttribute.getDescriptor(); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataProcessor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.57 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.57 Fri Nov 3 14:46:33 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataProcessor.java Sun Nov 5 13:07:29 2006 *************** *** 424,433 **** String mf, boolean throwException){ if (m_session == null){ AbstractSessionLog.getLog().log(SessionLog.CONFIG, SessionLog.EJB_ORM, EntityManagerSetupImpl.ERROR_LOADING_XML_FILE, ! e); } else if (!throwException) { // fail quietly m_session.log(SessionLog.CONFIG, --- 424,439 ---- String mf, boolean throwException){ if (m_session == null){ + // Metadata processor is mainly used with a session. + // Java SE bootstraping uses some functions such as ORM processing without + // a session. In these cases, it is impossible to get the + // session to properly handle the exception. As a result we + // log an error. The same code will be called later in the bootstrapping + // code and the error will be handled then. AbstractSessionLog.getLog().log(SessionLog.CONFIG, SessionLog.EJB_ORM, EntityManagerSetupImpl.ERROR_LOADING_XML_FILE, ! new Object[] {mf, e}); } else if (!throwException) { // fail quietly m_session.log(SessionLog.CONFIG, ================================================================================ Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/Base.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000014/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000014/AB0952363AC40CBFE034080020E8C54E.0 Sun Nov 5 13:06:38 2006 --- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/Base.java Sun Nov 5 13:06:37 2006 *************** *** 0 **** --- 1,107 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + + package oracle.toplink.essentials.testing.models.cmp3.instancecounting; + + import java.util.List; + import java.util.ArrayList; + + import javax.persistence.Basic; + import javax.persistence.Entity; + import javax.persistence.FetchType; + import javax.persistence.GeneratedValue; + import javax.persistence.Id; + import javax.persistence.JoinColumn; + import javax.persistence.JoinTable; + import javax.persistence.ManyToMany; + import javax.persistence.NamedQuery; + import javax.persistence.Table; + + @Entity + @Table(name = "IC_BASE") + @NamedQuery(name = "findAllBase", query = "SELECT b FROM Base b") + /** + * This class maintains a count on the number of instances of it that exist by incrementing a + * count each time a constructor is called and decrementing it when the class is finalized + * + * Care should be taken when using this class to ensure tests using it are completely cleaned up + * and the instanceCount is reset to 0. + */ + public class Base { + + private int id; + private List list; + private String name; + public static int instanceCount = 0; + + public Base(){ + list = new ArrayList(); + instanceCount++; + } + + public Base(String name){ + this(); + this.name = name; + } + + + @Id + @Basic + @GeneratedValue + public int getId(){ + return id; + } + + public void setId(int id){ + this.id = id; + } + + @ManyToMany(fetch = FetchType.LAZY) + @JoinTable(name = "BASE_LISTMEMBER_TABLE", + joinColumns = + @JoinColumn(name = "BASE_ID", referencedColumnName = "ID"), + inverseJoinColumns = + @JoinColumn(name = "MEMBER_NAME", referencedColumnName = "NAME")) + public List getList(){ + return list; + } + + public void setList(List list){ + this.list = list; + } + + public String getName(){ + return name; + } + + public void setName(String name){ + this.name = name; + } + + protected void finalize() throws Throwable + { + super.finalize(); + if (instanceCount != 0) { + instanceCount--; + } + } + } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/InstanceCountingTableCreator.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000015/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000015/AB0952363AC40CBFE034080020E8C54E.0 Sun Nov 5 13:06:42 2006 --- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/InstanceCountingTableCreator.java Sun Nov 5 13:06:41 2006 *************** *** 0 **** --- 1,117 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + + package oracle.toplink.essentials.testing.models.cmp3.instancecounting; + + import oracle.toplink.essentials.tools.schemaframework.FieldDefinition; + import oracle.toplink.essentials.tools.schemaframework.TableDefinition; + + public class InstanceCountingTableCreator extends oracle.toplink.essentials.tools.schemaframework.TableCreator { + + public InstanceCountingTableCreator() { + setName("InstanceCountingTableCreator"); + + addTableDefinition(buildBaseTable()); + addTableDefinition(buildListMemberTable()); + addTableDefinition(buildBASE_MEMBERTable()); + } + + public static TableDefinition buildBaseTable() { + TableDefinition table = new TableDefinition(); + // SECTION: TABLE + table.setName("IC_BASE"); + + // SECTION: FIELD + oracle.toplink.essentials.tools.schemaframework.FieldDefinition field = new oracle.toplink.essentials.tools.schemaframework.FieldDefinition(); + field.setName("ID"); + field.setTypeName("NUMERIC"); + field.setSize(15); + field.setShouldAllowNull(false ); + field.setIsPrimaryKey(true ); + field.setUnique(false ); + field.setIsIdentity(true ); + table.addField(field); + + // SECTION: FIELD + oracle.toplink.essentials.tools.schemaframework.FieldDefinition field1 = new oracle.toplink.essentials.tools.schemaframework.FieldDefinition(); + field1.setName("NAME"); + field1.setTypeName("VARCHAR"); + field1.setSize(40); + field1.setShouldAllowNull(true ); + field1.setIsPrimaryKey(false ); + field1.setUnique(false ); + field1.setIsIdentity(false ); + table.addField(field1); + + return table; + } + + public static TableDefinition buildListMemberTable() { + TableDefinition table = new TableDefinition(); + // SECTION: TABLE + table.setName("IC_LIST_MEMBER"); + + // SECTION: FIELD + oracle.toplink.essentials.tools.schemaframework.FieldDefinition field = new oracle.toplink.essentials.tools.schemaframework.FieldDefinition(); + field.setName("NAME"); + field.setTypeName("VARCHAR"); + field.setSize(40); + field.setShouldAllowNull(false ); + field.setIsPrimaryKey(true ); + field.setUnique(false ); + field.setIsIdentity(true ); + table.addField(field); + + return table; + } + + public static TableDefinition buildBASE_MEMBERTable() { + TableDefinition table = new TableDefinition(); + + table.setName("BASE_LISTMEMBER_TABLE"); + + // SECTION: FIELD + oracle.toplink.essentials.tools.schemaframework.FieldDefinition field = new oracle.toplink.essentials.tools.schemaframework.FieldDefinition(); + field.setName("BASE_ID"); + field.setTypeName("NUMERIC"); + field.setSize(15); + field.setShouldAllowNull(false ); + field.setIsPrimaryKey(true ); + field.setUnique(false ); + field.setIsIdentity(false ); + table.addField(field); + + // SECTION: FIELD + oracle.toplink.essentials.tools.schemaframework.FieldDefinition field1 = new oracle.toplink.essentials.tools.schemaframework.FieldDefinition(); + field1.setName("MEMBER_NAME"); + field1.setTypeName("VARCHAR"); + field1.setSize(40); + field1.setShouldAllowNull(false ); + field1.setIsPrimaryKey(true ); + field1.setUnique(false ); + field1.setIsIdentity(false ); + table.addField(field1); + + return table; + } + + } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/ListMember.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0 Sun Nov 5 13:06:45 2006 --- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/ListMember.java Sun Nov 5 13:06:45 2006 *************** *** 0 **** --- 1,96 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + + package oracle.toplink.essentials.testing.models.cmp3.instancecounting; + + import java.util.List; + import java.util.ArrayList; + + import javax.persistence.Basic; + import javax.persistence.Entity; + import javax.persistence.EntityManager; + import javax.persistence.Id; + import javax.persistence.ManyToMany; + import javax.persistence.NamedQueries; + import javax.persistence.NamedQuery; + import javax.persistence.Table; + + + /** + * This class maintains a count on the number of instances of it that exist by incrementing a + * count each time a constructor is called and decrementing it when the class is finalized + * + * Care should be taken when using this class to ensure tests using it are completely cleaned up + * and the instanceCount is reset to 0. + */ + @Entity + @Table(name = "IC_LIST_MEMBER") + @NamedQueries({ + @NamedQuery(name = "findAllListMember", + query = "SELECT m FROM ListMember m" + ), + @NamedQuery(name = "findAllListMemberByName", + query = "SELECT m FROM ListMember m where m.name = :name" + ) + }) + public class ListMember { + + public static int instanceCount =0; + private List base; + + private String name; + + public ListMember() { + instanceCount++; + base = new ArrayList(); + } + + public ListMember(String name) { + this(); + this.name = name; + } + + @Id + public String getName() { + return name; + } + + @ManyToMany(mappedBy = "list") + public List getBase() { + return base; + } + + public void setBase(List base) { + this.base = base; + } + + public void setName(String name) { + this.name = name; + } + + protected void finalize() throws Throwable { + super.finalize(); + if (instanceCount != 0) { + instanceCount--; + } + } + } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/instancecounting/MemoryLeakJUnitTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0 Sun Nov 5 13:06:49 2006 --- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/instancecounting/MemoryLeakJUnitTestSuite.java Sun Nov 5 13:06:48 2006 *************** *** 0 **** --- 1,144 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + + package oracle.toplink.essentials.testing.tests.cmp3.instancecounting; + + import java.util.List; + + import javax.persistence.EntityManager; + + import junit.extensions.TestSetup; + import junit.framework.Test; + import junit.framework.TestSuite; + + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.instancecounting.*; + import oracle.toplink.essentials.tools.schemaframework.SchemaManager; + + /** + * This test suite should be used to test fixes for bugs that result in memory leaks + * + */ + public class MemoryLeakJUnitTestSuite extends JUnitTestCase { + + public static String MEMBER_NAME = "member1"; + + public MemoryLeakJUnitTestSuite() { + super(); + } + + public MemoryLeakJUnitTestSuite(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite = new TestSuite(MemoryLeakJUnitTestSuite.class); + + return new TestSetup(suite) { + protected void setUp(){ + SchemaManager schemaManager = new SchemaManager(JUnitTestCase.getServerSession()); + new InstanceCountingTableCreator().replaceTables(JUnitTestCase.getServerSession(), schemaManager); + } + + protected void tearDown() { + clearCache(); + } + }; + } + + /* + * GF 1309 + * + * Test to ensure a memory leak related to queries holding instances of object + * through the query's ExpressionBuilder is fixed. + */ + public void testEntityManagerCleanUpForNamedQuery(){ + + int baseInstanceCount = Base.instanceCount; + int memberInstanceCount = ListMember.instanceCount; + // Populate the data + EntityManager em = createEntityManager(); + Base base = new Base("Base1"); + ListMember member = new ListMember(MEMBER_NAME); + base.getList().add(member); + member.getBase().add(base); + em.getTransaction().begin(); + em.persist(base); + em.persist(member); + em.getTransaction().commit(); + int baseId = base.getId(); + em.clear(); + em.close(); + base = null; + member = null; + + // Run some queries + em = createEntityManager(); + List results = em.createNamedQuery("findAllBase").getResultList(); + results = em.createNamedQuery("findAllListMember").getResultList(); + + // The following query will have an expression builder that caused the leak prior to the fix + results = em.createNamedQuery("findAllListMemberByName").setParameter("name", MEMBER_NAME).getResultList(); + + // get rid of references to the objects + results = null; + em.clear(); + em.close(); + clearCache(); + // Start the garbage collector + System.gc(); + + // Give the garbage collector some time to finish + int iterations = 0; + while (Base.instanceCount > 0 && ListMember.instanceCount > 0 && iterations < 100){ + iterations++; + try { + Thread.sleep(10); + } catch (InterruptedException exc){} + } + assertTrue("Base has not been garbage collected ", Base.instanceCount == baseInstanceCount); + assertTrue("ListMember has not been garbage collected ", ListMember.instanceCount == memberInstanceCount); + + // clean up + try{ + em = createEntityManager(); + em.getTransaction().begin(); + base = em.find(Base.class, new Integer(baseId)); + member = em.find(ListMember.class, MEMBER_NAME); + em.remove(base); + em.remove(member); + em.getTransaction().commit(); + } finally { + base = null; + member = null; + em.clear(); + em.close(); + clearCache(); + } + } + + public static void main(String[] args) { + // Now run JUnit. + junit.swingui.TestRunner.main(args); + } + + } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.24 Report generated at Sun Nov 5 13:07:29 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.24 Fri Nov 3 15:00:04 2006 --- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java Sun Nov 5 13:07:29 2006 *************** *** 64,69 **** --- 64,70 ---- import oracle.toplink.essentials.testing.tests.cmp3.xml.EntityMappingsJUnitTestSuite; import oracle.toplink.essentials.testing.tests.ejb.ejbqltesting.JUnitEJBQLInheritanceTestSuite; + import oracle.toplink.essentials.testing.tests.cmp3.instancecounting.MemoryLeakJUnitTestSuite; public class FullRegressionTestSuite extends TestSuite{ *************** *** 112,117 **** --- 113,121 ---- fullSuite.addTest(QueryParameterValidationTestSuite.suite()); fullSuite.addTest(UniAndBiDirectionalMappingTestSuite.suite()); + // Instance Counting Model + fullSuite.addTest(MemoryLeakJUnitTestSuite.suite()); + // EJBQL testing model fullSuite.addTest(JUnitEJBQLUnitTestSuite.suite()); fullSuite.addTest(JUnitEJBQLSimpleTestSuite.suite()); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/expressions/ExpressionBuilder.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.12 Report generated at Sun Nov 5 13:10:30 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000001/AB0952363AC40CBFE034080020E8C54E.12 Fri Nov 3 14:41:03 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/expressions/ExpressionBuilder.java Sun Nov 5 13:07:28 2006 *************** *** 257,263 **** if (this.queryClass != null) { Expression criteria = null; ! setSession(normalizer.getSession()); // The descriptor must be defined at this point. if (getDescriptor() == null) { throw QueryException.noExpressionBuilderFound(this); --- 257,263 ---- if (this.queryClass != null) { Expression criteria = null; ! setSession(normalizer.getSession().getRootSession(null)); // The descriptor must be defined at this point. if (getDescriptor() == null) { throw QueryException.noExpressionBuilderFound(this); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ObjectLevelReadQuery.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.24 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000002/AB0952363AC40CBFE034080020E8C54E.24 Fri Nov 3 14:41:43 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ObjectLevelReadQuery.java Sun Nov 5 13:07:28 2006 *************** *** 355,361 **** ObjectExpression objectExpression = (ObjectExpression)joinedExpressions.get(index); // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(getSession()); objectExpression.getBuilder().setQueryClass(getReferenceClass()); ClassDescriptor descriptor = objectExpression.getMapping().getReferenceDescriptor(); fields.addAll(descriptor.getFields()); --- 355,361 ---- ObjectExpression objectExpression = (ObjectExpression)joinedExpressions.get(index); // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(getSession().getRootSession(null)); objectExpression.getBuilder().setQueryClass(getReferenceClass()); ClassDescriptor descriptor = objectExpression.getMapping().getReferenceDescriptor(); fields.addAll(descriptor.getFields()); *************** *** 990,996 **** Expression expression = (Expression)fetchGroupAttrExps.get(index); // Expression may not have been initialized. ! expression.getBuilder().setSession(getSession()); expression.getBuilder().setQueryClass(getReferenceClass()); Helper.addAllToVector(fields, expression.getFields()); } --- 990,996 ---- Expression expression = (Expression)fetchGroupAttrExps.get(index); // Expression may not have been initialized. ! expression.getBuilder().setSession(getSession().getRootSession(null)); expression.getBuilder().setQueryClass(getReferenceClass()); Helper.addAllToVector(fields, expression.getFields()); } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ReadAllQuery.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.13 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.13 Fri Nov 3 14:41:44 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ReadAllQuery.java Sun Nov 5 13:07:29 2006 *************** *** 206,212 **** if (getSelectionCriteria() != null) { selectionCriteriaClone = (Expression)getSelectionCriteria().clone(); ! selectionCriteriaClone.getBuilder().setSession(unitOfWork); selectionCriteriaClone.getBuilder().setQueryClass(getReferenceClass()); } cp = getContainerPolicy(); --- 206,212 ---- if (getSelectionCriteria() != null) { selectionCriteriaClone = (Expression)getSelectionCriteria().clone(); ! selectionCriteriaClone.getBuilder().setSession(unitOfWork.getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(getReferenceClass()); } cp = getContainerPolicy(); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ReadObjectQuery.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.13 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.13 Fri Nov 3 14:41:44 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/queryframework/ReadObjectQuery.java Sun Nov 5 13:07:29 2006 *************** *** 300,306 **** Expression selectionCriteriaClone = null; if ((getSelectionCriteria() != null) && (getSelectionKey() == null) && (getSelectionObject() == null)) { selectionCriteriaClone = (Expression)getSelectionCriteria().clone(); ! selectionCriteriaClone.getBuilder().setSession(unitOfWork); selectionCriteriaClone.getBuilder().setQueryClass(getReferenceClass()); } --- 300,306 ---- Expression selectionCriteriaClone = null; if ((getSelectionCriteria() != null) && (getSelectionKey() == null) && (getSelectionObject() == null)) { selectionCriteriaClone = (Expression)getSelectionCriteria().clone(); ! selectionCriteriaClone.getBuilder().setSession(unitOfWork.getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(getReferenceClass()); } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/descriptors/ObjectBuilder.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.29 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.29 Fri Nov 3 14:43:44 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/descriptors/ObjectBuilder.java Sun Nov 5 13:07:29 2006 *************** *** 1442,1451 **** //put the curent session onthe expression builder for use later store current session incase //it is required at a later stage AbstractSession oldSession = expression.getBuilder().getSession(); ! expression.getBuilder().setSession(session); // Get all the field & values from expression. boolean isValid = expression.extractPrimaryKeyValues(requiresExactMatch, getDescriptor(), primaryKeyRow, translationRow); - expression.getBuilder().setSession(oldSession); if (requiresExactMatch && (!isValid)) { return null; } --- 1442,1450 ---- //put the curent session onthe expression builder for use later store current session incase //it is required at a later stage AbstractSession oldSession = expression.getBuilder().getSession(); ! expression.getBuilder().setSession(session.getRootSession(null)); // Get all the field & values from expression. boolean isValid = expression.extractPrimaryKeyValues(requiresExactMatch, getDescriptor(), primaryKeyRow, translationRow); if (requiresExactMatch && (!isValid)) { return null; } *************** *** 1540,1549 **** //put the curent session onthe expression builder for use later store current session incase //it is required at a later stage AbstractSession oldSession = expression.getBuilder().getSession(); ! expression.getBuilder().setSession(session); // Get all the field & values from expression boolean isValid = expression.extractPrimaryKeyValues(true, getDescriptor(), primaryKeyRow, translationRow); ! expression.getBuilder().setSession(session); if (!isValid) { return null; } --- 1539,1548 ---- //put the curent session onthe expression builder for use later store current session incase //it is required at a later stage AbstractSession oldSession = expression.getBuilder().getSession(); ! expression.getBuilder().setSession(session.getRootSession(null)); // Get all the field & values from expression boolean isValid = expression.extractPrimaryKeyValues(true, getDescriptor(), primaryKeyRow, translationRow); ! expression.getBuilder().setSession(session.getRootSession(null)); if (!isValid) { return null; } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/expressions/CompoundExpression.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.7 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.7 Fri Nov 3 14:43:48 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/expressions/CompoundExpression.java Sun Nov 5 13:07:29 2006 *************** *** 164,170 **** //let's make sure a session is available in the case of a parallel expression ExpressionBuilder builder = getFirstChild().getBuilder(); if (builder != null){ ! builder.setSession(normalizer.getSession()); } setFirstChild(getFirstChild().normalize(normalizer)); } --- 164,170 ---- //let's make sure a session is available in the case of a parallel expression ExpressionBuilder builder = getFirstChild().getBuilder(); if (builder != null){ ! builder.setSession(normalizer.getSession().getRootSession(null)); } setFirstChild(getFirstChild().normalize(normalizer)); } *************** *** 172,178 **** //let's make sure a session is available in the case of a parallel expression ExpressionBuilder builder = getSecondChild().getBuilder(); if (builder != null){ ! builder.setSession(normalizer.getSession()); } setSecondChild(getSecondChild().normalize(normalizer)); } --- 172,178 ---- //let's make sure a session is available in the case of a parallel expression ExpressionBuilder builder = getSecondChild().getBuilder(); if (builder != null){ ! builder.setSession(normalizer.getSession().getRootSession(null)); } setSecondChild(getSecondChild().normalize(normalizer)); } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/expressions/SQLSelectStatement.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.21 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.21 Fri Nov 3 14:43:48 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/expressions/SQLSelectStatement.java Sun Nov 5 13:07:29 2006 *************** *** 1091,1097 **** setWhereClause(null); } ! builder.setSession(session); // Some queries are not on objects but for data, thus no descriptor. if (!builder.doesNotRepresentAnObjectInTheQuery()) { --- 1091,1097 ---- setWhereClause(null); } ! builder.setSession(session.getRootSession(null)); // Some queries are not on objects but for data, thus no descriptor. if (!builder.doesNotRepresentAnObjectInTheQuery()) { ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/identitymaps/IdentityMapManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.14 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000008/AB0952363AC40CBFE034080020E8C54E.14 Fri Nov 3 14:43:48 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/identitymaps/IdentityMapManager.java Sun Nov 5 13:07:29 2006 *************** *** 369,375 **** // Only clone if required. if ((selectionCriteria != null) && (selectionCriteriaClone.getBuilder().getSession() == null)) { selectionCriteriaClone = (Expression)selectionCriteria.clone(); ! selectionCriteriaClone.getBuilder().setSession(getSession()); selectionCriteriaClone.getBuilder().setQueryClass(theClass); } objects = new Vector(); --- 369,375 ---- // Only clone if required. if ((selectionCriteria != null) && (selectionCriteriaClone.getBuilder().getSession() == null)) { selectionCriteriaClone = (Expression)selectionCriteria.clone(); ! selectionCriteriaClone.getBuilder().setSession(getSession().getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(theClass); } objects = new Vector(); *************** *** 555,561 **** // Only clone if required. if ((selectionCriteria != null) && (selectionCriteriaClone.getBuilder().getSession() == null)) { selectionCriteriaClone = (Expression)selectionCriteria.clone(); ! selectionCriteriaClone.getBuilder().setSession(getSession()); selectionCriteriaClone.getBuilder().setQueryClass(theClass); } IdentityMap map = getIdentityMap(descriptor); --- 555,561 ---- // Only clone if required. if ((selectionCriteria != null) && (selectionCriteriaClone.getBuilder().getSession() == null)) { selectionCriteriaClone = (Expression)selectionCriteria.clone(); ! selectionCriteriaClone.getBuilder().setSession(getSession().getRootSession(null)); selectionCriteriaClone.getBuilder().setQueryClass(theClass); } IdentityMap map = getIdentityMap(descriptor); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/ExpressionQueryMechanism.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.32 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000009/AB0952363AC40CBFE034080020E8C54E.32 Sun Nov 5 13:03:43 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/ExpressionQueryMechanism.java Sun Nov 5 13:07:29 2006 *************** *** 589,595 **** updateAllStatement.setWhereClause(getSelectionCriteria()); if(updateAllStatement.getWhereClause() != null) { updateAllStatement.setWhereClause((Expression)updateAllStatement.getWhereClause().clone()); ! updateAllStatement.getWhereClause().getBuilder().setSession(getSession()); updateAllStatement.getWhereClause().getBuilder().setQueryClass(getQuery().getReferenceClass()); } } --- 589,595 ---- updateAllStatement.setWhereClause(getSelectionCriteria()); if(updateAllStatement.getWhereClause() != null) { updateAllStatement.setWhereClause((Expression)updateAllStatement.getWhereClause().clone()); ! updateAllStatement.getWhereClause().getBuilder().setSession(getSession().getRootSession(null)); updateAllStatement.getWhereClause().getBuilder().setQueryClass(getQuery().getReferenceClass()); } } *************** *** 1526,1532 **** if(field == null) { DataExpression fieldExpressionClone = (DataExpression)fieldExpression.clone(); fieldExpressionClone.getBuilder().setQueryClass(getQuery().getReferenceClass()); ! fieldExpressionClone.getBuilder().setSession(getSession()); field = fieldExpressionClone.getField(); if(field == null) { throw QueryException.updateAllQueryAddUpdateDoesNotDefineField(getDescriptor(), getQuery(), fieldExpression.toString()); --- 1526,1532 ---- if(field == null) { DataExpression fieldExpressionClone = (DataExpression)fieldExpression.clone(); fieldExpressionClone.getBuilder().setQueryClass(getQuery().getReferenceClass()); ! fieldExpressionClone.getBuilder().setSession(getSession().getRootSession(null)); field = fieldExpressionClone.getField(); if(field == null) { throw QueryException.updateAllQueryAddUpdateDoesNotDefineField(getDescriptor(), getQuery(), fieldExpression.toString()); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/JoinedAttributeManager.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.5 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000010/AB0952363AC40CBFE034080020E8C54E.5 Fri Nov 3 14:43:48 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/queryframework/JoinedAttributeManager.java Sun Nov 5 13:07:29 2006 *************** *** 198,204 **** ObjectExpression objectExpression = (ObjectExpression)joinedExpressions.get(index); // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(session); objectExpression.getBuilder().setQueryClass(getDescriptor().getJavaClass()); // PERF: Cache join attribute names. --- 198,204 ---- ObjectExpression objectExpression = (ObjectExpression)joinedExpressions.get(index); // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(session.getRootSession(null)); objectExpression.getBuilder().setQueryClass(getDescriptor().getJavaClass()); // PERF: Cache join attribute names. *************** *** 537,543 **** QueryKeyExpression objectExpression = (QueryKeyExpression)expression; // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(session); if (objectExpression.getBuilder().getQueryClass() == null){ objectExpression.getBuilder().setQueryClass(this.descriptor.getJavaClass()); } --- 537,543 ---- QueryKeyExpression objectExpression = (QueryKeyExpression)expression; // Expression may not have been initialized. ! objectExpression.getBuilder().setSession(session.getRootSession(null)); if (objectExpression.getBuilder().getQueryClass() == null){ objectExpression.getBuilder().setQueryClass(this.descriptor.getJavaClass()); } *************** *** 682,688 **** ObjectExpression joinedAttribute = (ObjectExpression)expression; // Expression may not have been initialized. ! joinedAttribute.getBuilder().setSession(session); joinedAttribute.getBuilder().setQueryClass(getDescriptor().getJavaClass()); ClassDescriptor nestedDescriptor = null;// joinedAttribute.getDescriptor(); --- 682,688 ---- ObjectExpression joinedAttribute = (ObjectExpression)expression; // Expression may not have been initialized. ! joinedAttribute.getBuilder().setSession(session.getRootSession(null)); joinedAttribute.getBuilder().setQueryClass(getDescriptor().getJavaClass()); ClassDescriptor nestedDescriptor = null;// joinedAttribute.getDescriptor(); ================================================================================ Merge Diffs: /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataProcessor.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.57 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000011/AB0952363AC40CBFE034080020E8C54E.57 Fri Nov 3 14:46:33 2006 --- /ade/tware_toplink10i/tldev/source/essentials/oracle/toplink/essentials/internal/ejb/cmp3/metadata/MetadataProcessor.java Sun Nov 5 13:07:29 2006 *************** *** 424,433 **** String mf, boolean throwException){ if (m_session == null){ AbstractSessionLog.getLog().log(SessionLog.CONFIG, SessionLog.EJB_ORM, EntityManagerSetupImpl.ERROR_LOADING_XML_FILE, ! e); } else if (!throwException) { // fail quietly m_session.log(SessionLog.CONFIG, --- 424,439 ---- String mf, boolean throwException){ if (m_session == null){ + // Metadata processor is mainly used with a session. + // Java SE bootstraping uses some functions such as ORM processing without + // a session. In these cases, it is impossible to get the + // session to properly handle the exception. As a result we + // log an error. The same code will be called later in the bootstrapping + // code and the error will be handled then. AbstractSessionLog.getLog().log(SessionLog.CONFIG, SessionLog.EJB_ORM, EntityManagerSetupImpl.ERROR_LOADING_XML_FILE, ! new Object[] {mf, e}); } else if (!throwException) { // fail quietly m_session.log(SessionLog.CONFIG, ================================================================================ Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/Base.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000014/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000014/AB0952363AC40CBFE034080020E8C54E.0 Sun Nov 5 13:06:38 2006 --- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/Base.java Sun Nov 5 13:06:37 2006 *************** *** 0 **** --- 1,107 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + + package oracle.toplink.essentials.testing.models.cmp3.instancecounting; + + import java.util.List; + import java.util.ArrayList; + + import javax.persistence.Basic; + import javax.persistence.Entity; + import javax.persistence.FetchType; + import javax.persistence.GeneratedValue; + import javax.persistence.Id; + import javax.persistence.JoinColumn; + import javax.persistence.JoinTable; + import javax.persistence.ManyToMany; + import javax.persistence.NamedQuery; + import javax.persistence.Table; + + @Entity + @Table(name = "IC_BASE") + @NamedQuery(name = "findAllBase", query = "SELECT b FROM Base b") + /** + * This class maintains a count on the number of instances of it that exist by incrementing a + * count each time a constructor is called and decrementing it when the class is finalized + * + * Care should be taken when using this class to ensure tests using it are completely cleaned up + * and the instanceCount is reset to 0. + */ + public class Base { + + private int id; + private List list; + private String name; + public static int instanceCount = 0; + + public Base(){ + list = new ArrayList(); + instanceCount++; + } + + public Base(String name){ + this(); + this.name = name; + } + + + @Id + @Basic + @GeneratedValue + public int getId(){ + return id; + } + + public void setId(int id){ + this.id = id; + } + + @ManyToMany(fetch = FetchType.LAZY) + @JoinTable(name = "BASE_LISTMEMBER_TABLE", + joinColumns = + @JoinColumn(name = "BASE_ID", referencedColumnName = "ID"), + inverseJoinColumns = + @JoinColumn(name = "MEMBER_NAME", referencedColumnName = "NAME")) + public List getList(){ + return list; + } + + public void setList(List list){ + this.list = list; + } + + public String getName(){ + return name; + } + + public void setName(String name){ + this.name = name; + } + + protected void finalize() throws Throwable + { + super.finalize(); + if (instanceCount != 0) { + instanceCount--; + } + } + } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/InstanceCountingTableCreator.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000015/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000015/AB0952363AC40CBFE034080020E8C54E.0 Sun Nov 5 13:06:42 2006 --- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/InstanceCountingTableCreator.java Sun Nov 5 13:06:41 2006 *************** *** 0 **** --- 1,117 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + + package oracle.toplink.essentials.testing.models.cmp3.instancecounting; + + import oracle.toplink.essentials.tools.schemaframework.FieldDefinition; + import oracle.toplink.essentials.tools.schemaframework.TableDefinition; + + public class InstanceCountingTableCreator extends oracle.toplink.essentials.tools.schemaframework.TableCreator { + + public InstanceCountingTableCreator() { + setName("InstanceCountingTableCreator"); + + addTableDefinition(buildBaseTable()); + addTableDefinition(buildListMemberTable()); + addTableDefinition(buildBASE_MEMBERTable()); + } + + public static TableDefinition buildBaseTable() { + TableDefinition table = new TableDefinition(); + // SECTION: TABLE + table.setName("IC_BASE"); + + // SECTION: FIELD + oracle.toplink.essentials.tools.schemaframework.FieldDefinition field = new oracle.toplink.essentials.tools.schemaframework.FieldDefinition(); + field.setName("ID"); + field.setTypeName("NUMERIC"); + field.setSize(15); + field.setShouldAllowNull(false ); + field.setIsPrimaryKey(true ); + field.setUnique(false ); + field.setIsIdentity(true ); + table.addField(field); + + // SECTION: FIELD + oracle.toplink.essentials.tools.schemaframework.FieldDefinition field1 = new oracle.toplink.essentials.tools.schemaframework.FieldDefinition(); + field1.setName("NAME"); + field1.setTypeName("VARCHAR"); + field1.setSize(40); + field1.setShouldAllowNull(true ); + field1.setIsPrimaryKey(false ); + field1.setUnique(false ); + field1.setIsIdentity(false ); + table.addField(field1); + + return table; + } + + public static TableDefinition buildListMemberTable() { + TableDefinition table = new TableDefinition(); + // SECTION: TABLE + table.setName("IC_LIST_MEMBER"); + + // SECTION: FIELD + oracle.toplink.essentials.tools.schemaframework.FieldDefinition field = new oracle.toplink.essentials.tools.schemaframework.FieldDefinition(); + field.setName("NAME"); + field.setTypeName("VARCHAR"); + field.setSize(40); + field.setShouldAllowNull(false ); + field.setIsPrimaryKey(true ); + field.setUnique(false ); + field.setIsIdentity(true ); + table.addField(field); + + return table; + } + + public static TableDefinition buildBASE_MEMBERTable() { + TableDefinition table = new TableDefinition(); + + table.setName("BASE_LISTMEMBER_TABLE"); + + // SECTION: FIELD + oracle.toplink.essentials.tools.schemaframework.FieldDefinition field = new oracle.toplink.essentials.tools.schemaframework.FieldDefinition(); + field.setName("BASE_ID"); + field.setTypeName("NUMERIC"); + field.setSize(15); + field.setShouldAllowNull(false ); + field.setIsPrimaryKey(true ); + field.setUnique(false ); + field.setIsIdentity(false ); + table.addField(field); + + // SECTION: FIELD + oracle.toplink.essentials.tools.schemaframework.FieldDefinition field1 = new oracle.toplink.essentials.tools.schemaframework.FieldDefinition(); + field1.setName("MEMBER_NAME"); + field1.setTypeName("VARCHAR"); + field1.setSize(40); + field1.setShouldAllowNull(false ); + field1.setIsPrimaryKey(true ); + field1.setUnique(false ); + field1.setIsIdentity(false ); + table.addField(field1); + + return table; + } + + } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/ListMember.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000016/AB0952363AC40CBFE034080020E8C54E.0 Sun Nov 5 13:06:45 2006 --- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/instancecounting/ListMember.java Sun Nov 5 13:06:45 2006 *************** *** 0 **** --- 1,96 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + + package oracle.toplink.essentials.testing.models.cmp3.instancecounting; + + import java.util.List; + import java.util.ArrayList; + + import javax.persistence.Basic; + import javax.persistence.Entity; + import javax.persistence.EntityManager; + import javax.persistence.Id; + import javax.persistence.ManyToMany; + import javax.persistence.NamedQueries; + import javax.persistence.NamedQuery; + import javax.persistence.Table; + + + /** + * This class maintains a count on the number of instances of it that exist by incrementing a + * count each time a constructor is called and decrementing it when the class is finalized + * + * Care should be taken when using this class to ensure tests using it are completely cleaned up + * and the instanceCount is reset to 0. + */ + @Entity + @Table(name = "IC_LIST_MEMBER") + @NamedQueries({ + @NamedQuery(name = "findAllListMember", + query = "SELECT m FROM ListMember m" + ), + @NamedQuery(name = "findAllListMemberByName", + query = "SELECT m FROM ListMember m where m.name = :name" + ) + }) + public class ListMember { + + public static int instanceCount =0; + private List base; + + private String name; + + public ListMember() { + instanceCount++; + base = new ArrayList(); + } + + public ListMember(String name) { + this(); + this.name = name; + } + + @Id + public String getName() { + return name; + } + + @ManyToMany(mappedBy = "list") + public List getBase() { + return base; + } + + public void setBase(List base) { + this.base = base; + } + + public void setName(String name) { + this.name = name; + } + + protected void finalize() throws Throwable { + super.finalize(); + if (instanceCount != 0) { + instanceCount--; + } + } + } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/instancecounting/MemoryLeakJUnitTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000019/AB0952363AC40CBFE034080020E8C54E.0 Sun Nov 5 13:06:49 2006 --- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/instancecounting/MemoryLeakJUnitTestSuite.java Sun Nov 5 13:06:48 2006 *************** *** 0 **** --- 1,144 ---- + /* + * The contents of this file are subject to the terms + * of the Common Development and Distribution License + * (the "License"). You may not use this file except + * in compliance with the License. + * + * You can obtain a copy of the license at + * glassfish/bootstrap/legal/CDDLv1.0.txt or + * https://glassfish.dev.java.net/public/CDDLv1.0.html. + * See the License for the specific language governing + * permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL + * HEADER in each file and include the License file at + * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, + * add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your + * own identifying information: Portions Copyright [yyyy] + * [name of copyright owner] + */ + // Copyright (c) 1998, 2006, Oracle. All rights reserved. + + package oracle.toplink.essentials.testing.tests.cmp3.instancecounting; + + import java.util.List; + + import javax.persistence.EntityManager; + + import junit.extensions.TestSetup; + import junit.framework.Test; + import junit.framework.TestSuite; + + import oracle.toplink.essentials.testing.framework.junit.JUnitTestCase; + import oracle.toplink.essentials.testing.models.cmp3.instancecounting.*; + import oracle.toplink.essentials.tools.schemaframework.SchemaManager; + + /** + * This test suite should be used to test fixes for bugs that result in memory leaks + * + */ + public class MemoryLeakJUnitTestSuite extends JUnitTestCase { + + public static String MEMBER_NAME = "member1"; + + public MemoryLeakJUnitTestSuite() { + super(); + } + + public MemoryLeakJUnitTestSuite(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite = new TestSuite(MemoryLeakJUnitTestSuite.class); + + return new TestSetup(suite) { + protected void setUp(){ + SchemaManager schemaManager = new SchemaManager(JUnitTestCase.getServerSession()); + new InstanceCountingTableCreator().replaceTables(JUnitTestCase.getServerSession(), schemaManager); + } + + protected void tearDown() { + clearCache(); + } + }; + } + + /* + * GF 1309 + * + * Test to ensure a memory leak related to queries holding instances of object + * through the query's ExpressionBuilder is fixed. + */ + public void testEntityManagerCleanUpForNamedQuery(){ + + int baseInstanceCount = Base.instanceCount; + int memberInstanceCount = ListMember.instanceCount; + // Populate the data + EntityManager em = createEntityManager(); + Base base = new Base("Base1"); + ListMember member = new ListMember(MEMBER_NAME); + base.getList().add(member); + member.getBase().add(base); + em.getTransaction().begin(); + em.persist(base); + em.persist(member); + em.getTransaction().commit(); + int baseId = base.getId(); + em.clear(); + em.close(); + base = null; + member = null; + + // Run some queries + em = createEntityManager(); + List results = em.createNamedQuery("findAllBase").getResultList(); + results = em.createNamedQuery("findAllListMember").getResultList(); + + // The following query will have an expression builder that caused the leak prior to the fix + results = em.createNamedQuery("findAllListMemberByName").setParameter("name", MEMBER_NAME).getResultList(); + + // get rid of references to the objects + results = null; + em.clear(); + em.close(); + clearCache(); + // Start the garbage collector + System.gc(); + + // Give the garbage collector some time to finish + int iterations = 0; + while (Base.instanceCount > 0 && ListMember.instanceCount > 0 && iterations < 100){ + iterations++; + try { + Thread.sleep(10); + } catch (InterruptedException exc){} + } + assertTrue("Base has not been garbage collected ", Base.instanceCount == baseInstanceCount); + assertTrue("ListMember has not been garbage collected ", ListMember.instanceCount == memberInstanceCount); + + // clean up + try{ + em = createEntityManager(); + em.getTransaction().begin(); + base = em.find(Base.class, new Integer(baseId)); + member = em.find(ListMember.class, MEMBER_NAME); + em.remove(base); + em.remove(member); + em.getTransaction().commit(); + } finally { + base = null; + member = null; + em.clear(); + em.close(); + clearCache(); + } + } + + public static void main(String[] args) { + // Now run JUnit. + junit.swingui.TestRunner.main(args); + } + + } ================================================================================ Merge Diffs: /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.24 Report generated at Sun Nov 5 13:10:31 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/tware/tware_10essentials_gf1309_expression_builder_memory_leak_061102/ade_storage/000020/AB0952363AC40CBFE034080020E8C54E.24 Fri Nov 3 15:00:04 2006 --- /ade/tware_toplink10i/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/FullRegressionTestSuite.java Sun Nov 5 13:07:29 2006 *************** *** 64,69 **** --- 64,70 ---- import oracle.toplink.essentials.testing.tests.cmp3.xml.EntityMappingsJUnitTestSuite; import oracle.toplink.essentials.testing.tests.ejb.ejbqltesting.JUnitEJBQLInheritanceTestSuite; + import oracle.toplink.essentials.testing.tests.cmp3.instancecounting.MemoryLeakJUnitTestSuite; public class FullRegressionTestSuite extends TestSuite{ *************** *** 112,117 **** --- 113,121 ---- fullSuite.addTest(QueryParameterValidationTestSuite.suite()); fullSuite.addTest(UniAndBiDirectionalMappingTestSuite.suite()); + // Instance Counting Model + fullSuite.addTest(MemoryLeakJUnitTestSuite.suite()); + // EJBQL testing model fullSuite.addTest(JUnitEJBQLUnitTestSuite.suite()); fullSuite.addTest(JUnitEJBQLSimpleTestSuite.suite());