View | Details | Raw Unified | Return to bug 321763
Collapse All | Expand All

(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/tools/sessionconsole/ProfileBrowser.java (-2 / +2 lines)
Lines 45-51 Link Here
45
     * PUBLIC:
45
     * PUBLIC:
46
     * Open a browser on the profiles.
46
     * Open a browser on the profiles.
47
     */
47
     */
48
    public static void browseProfiles(Vector profiles) {
48
    public static void browseProfiles(List<Profile> profiles) {
49
        try {
49
        try {
50
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
50
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
51
            ProfileBrowser aProfileBrowserFrame;
51
            ProfileBrowser aProfileBrowserFrame;
Lines 171-177 Link Here
171
        // user code end
171
        // user code end
172
    }
172
    }
173
173
174
    public void setProfiles(Vector profiles) {
174
    public void setProfiles(List<Profile> profiles) {
175
        getProfileBrowserPanel().setProfiles(profiles);
175
        getProfileBrowserPanel().setProfiles(profiles);
176
    }
176
    }
177
}
177
}
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/tools/sessionconsole/ProfileBrowserPanel.java (-37 / +24 lines)
Lines 13-18 Link Here
13
package org.eclipse.persistence.tools.sessionconsole;
13
package org.eclipse.persistence.tools.sessionconsole;
14
14
15
import java.util.*;
15
import java.util.*;
16
16
import javax.swing.*;
17
import javax.swing.*;
17
import javax.swing.table.*;
18
import javax.swing.table.*;
18
19
Lines 25-31 Link Here
25
 * This panel allows for the browsing of performance profiles.
26
 * This panel allows for the browsing of performance profiles.
26
 */
27
 */
27
public class ProfileBrowserPanel extends JPanel {
28
public class ProfileBrowserPanel extends JPanel {
28
    private java.util.Vector fieldProfiles = new java.util.Vector();
29
    private List<Profile> fieldProfiles = new ArrayList();
29
    private JScrollPane ivjProfileScrollPane = null;
30
    private JScrollPane ivjProfileScrollPane = null;
30
    private JTable ivjProfilesTable = null;
31
    private JTable ivjProfilesTable = null;
31
    private JComboBox ivjGroupByChoice = null;
32
    private JComboBox ivjGroupByChoice = null;
Lines 88-96 Link Here
88
    public Vector buildProfileSummaryByClass() {
89
    public Vector buildProfileSummaryByClass() {
89
        Hashtable summaries = new Hashtable();
90
        Hashtable summaries = new Hashtable();
90
91
91
        for (Enumeration enumtr = getProfiles().elements(); 
92
        for (Profile profile : getProfiles()) {
92
             enumtr.hasMoreElements(); ) {
93
            Profile profile = (Profile)enumtr.nextElement();
94
            Class domainClass = profile.getDomainClass();
93
            Class domainClass = profile.getDomainClass();
95
            if (domainClass == null) {
94
            if (domainClass == null) {
96
                domainClass = Void.class;
95
                domainClass = Void.class;
Lines 140-148 Link Here
140
    public Vector buildProfileSummaryByQuery() {
139
    public Vector buildProfileSummaryByQuery() {
141
        Hashtable summaries = new Hashtable();
140
        Hashtable summaries = new Hashtable();
142
141
143
        for (Enumeration enumtr = getProfiles().elements(); 
142
        for (Profile profile : getProfiles()) {
144
             enumtr.hasMoreElements(); ) {
145
            Profile profile = (Profile)enumtr.nextElement();
146
            Class queryType = profile.getQueryClass();
143
            Class queryType = profile.getQueryClass();
147
            //CR 3050 PWK - If we don't know the query class, we need to use void.
144
            //CR 3050 PWK - If we don't know the query class, we need to use void.
148
            //This avoids a null pointer exception when adding to the hashtable.
145
            //This avoids a null pointer exception when adding to the hashtable.
Lines 193-201 Link Here
193
    public Vector buildProfileSummaryByQueryAndClass() {
190
    public Vector buildProfileSummaryByQueryAndClass() {
194
        Hashtable summaries = new Hashtable();
191
        Hashtable summaries = new Hashtable();
195
192
196
        for (Enumeration enumtr = getProfiles().elements(); 
193
        for (Profile profile : getProfiles()) {
197
             enumtr.hasMoreElements(); ) {
198
            Profile profile = (Profile)enumtr.nextElement();
199
            Class queryType = profile.getQueryClass();
194
            Class queryType = profile.getQueryClass();
200
            Class queryClass = profile.getDomainClass();
195
            Class queryClass = profile.getDomainClass();
201
            if (queryClass == null) {
196
            if (queryClass == null) {
Lines 333-344 Link Here
333
        return ivjGroupByLabel;
328
        return ivjGroupByLabel;
334
    }
329
    }
335
330
336
    /**
331
    public List<Profile> getProfiles() {
337
     * Gets the profiles property (java.util.Vector) value.
338
     * @return The profiles property value.
339
     * @see #setProfiles
340
     */
341
    public java.util.Vector getProfiles() {
342
        return fieldProfiles;
332
        return fieldProfiles;
343
    }
333
    }
344
334
Lines 501-507 Link Here
501
        columns.addElement("SQL Generation");
491
        columns.addElement("SQL Generation");
502
        model.setColumnIdentifiers(columns);
492
        model.setColumnIdentifiers(columns);
503
493
504
        Vector profiles = getProfiles();
494
        List<Profile> profiles = getProfiles();
505
        if (getGroupByChoice().getModel().getSelectedItem().equals("Group By Query")) {
495
        if (getGroupByChoice().getModel().getSelectedItem().equals("Group By Query")) {
506
            profiles = buildProfileSummaryByQuery();
496
            profiles = buildProfileSummaryByQuery();
507
        } else if (getGroupByChoice().getModel().getSelectedItem().equals("Group By Class")) {
497
        } else if (getGroupByChoice().getModel().getSelectedItem().equals("Group By Class")) {
Lines 510-519 Link Here
510
            profiles = buildProfileSummaryByQueryAndClass();
500
            profiles = buildProfileSummaryByQueryAndClass();
511
        }
501
        }
512
502
513
        for (Enumeration profileEnum = profiles.elements(); 
503
        for (Profile profile : profiles) {
514
             profileEnum.hasMoreElements(); ) {
515
            Profile profile = (Profile)profileEnum.nextElement();
516
517
            String items[] = new String[13];
504
            String items[] = new String[13];
518
            if (profile.getQueryClass() == null) {
505
            if (profile.getQueryClass() == null) {
519
                items[0] = "";
506
                items[0] = "";
Lines 535-579 Link Here
535
            items[4] = 
522
            items[4] = 
536
                    new Long(profile.getNumberOfInstancesEffected()).toString();
523
                    new Long(profile.getNumberOfInstancesEffected()).toString();
537
            items[5] = new Long(profile.getObjectsPerSecond()).toString();
524
            items[5] = new Long(profile.getObjectsPerSecond()).toString();
538
            if (profile.getOperationTimings().containsKey(SessionProfiler.SQL_PREPARE)) {
525
            if (profile.getOperationTimings().containsKey(SessionProfiler.SqlPrepare)) {
539
                items[6] = 
526
                items[6] = 
540
                        profile.getOperationTimings().get(SessionProfiler.SQL_PREPARE).toString();
527
                        profile.getOperationTimings().get(SessionProfiler.SqlPrepare).toString();
541
            } else {
528
            } else {
542
                items[6] = "";
529
                items[6] = "";
543
            }
530
            }
544
            if (profile.getOperationTimings().containsKey(SessionProfiler.STATEMENT_EXECUTE)) {
531
            if (profile.getOperationTimings().containsKey(SessionProfiler.StatementExecute)) {
545
                items[7] = 
532
                items[7] = 
546
                        profile.getOperationTimings().get(SessionProfiler.STATEMENT_EXECUTE).toString();
533
                        profile.getOperationTimings().get(SessionProfiler.StatementExecute).toString();
547
            } else {
534
            } else {
548
                items[7] = "";
535
                items[7] = "";
549
            }
536
            }
550
            if (profile.getOperationTimings().containsKey(SessionProfiler.ROW_FETCH)) {
537
            if (profile.getOperationTimings().containsKey(SessionProfiler.RowFetch)) {
551
                items[8] = 
538
                items[8] = 
552
                        profile.getOperationTimings().get(SessionProfiler.ROW_FETCH).toString();
539
                        profile.getOperationTimings().get(SessionProfiler.RowFetch).toString();
553
            } else {
540
            } else {
554
                items[8] = "";
541
                items[8] = "";
555
            }
542
            }
556
            if (profile.getOperationTimings().containsKey(SessionProfiler.CACHE)) {
543
            if (profile.getOperationTimings().containsKey(SessionProfiler.Caching)) {
557
                items[9] = 
544
                items[9] = 
558
                        profile.getOperationTimings().get(SessionProfiler.CACHE).toString();
545
                        profile.getOperationTimings().get(SessionProfiler.Caching).toString();
559
            } else {
546
            } else {
560
                items[9] = "";
547
                items[9] = "";
561
            }
548
            }
562
            if (profile.getOperationTimings().containsKey(SessionProfiler.OBJECT_BUILDING)) {
549
            if (profile.getOperationTimings().containsKey(SessionProfiler.ObjectBuilding)) {
563
                items[10] = 
550
                items[10] = 
564
                        profile.getOperationTimings().get(SessionProfiler.OBJECT_BUILDING).toString();
551
                        profile.getOperationTimings().get(SessionProfiler.ObjectBuilding).toString();
565
            } else {
552
            } else {
566
                items[10] = "";
553
                items[10] = "";
567
            }
554
            }
568
            if (profile.getOperationTimings().containsKey(SessionProfiler.QUERY_PREPARE)) {
555
            if (profile.getOperationTimings().containsKey(SessionProfiler.QueryPreparation)) {
569
                items[11] = 
556
                items[11] = 
570
                        profile.getOperationTimings().get(SessionProfiler.QUERY_PREPARE).toString();
557
                        profile.getOperationTimings().get(SessionProfiler.QueryPreparation).toString();
571
            } else {
558
            } else {
572
                items[11] = "";
559
                items[11] = "";
573
            }
560
            }
574
            if (profile.getOperationTimings().containsKey(SessionProfiler.SQL_GENERATION)) {
561
            if (profile.getOperationTimings().containsKey(SessionProfiler.SqlGeneration)) {
575
                items[12] = 
562
                items[12] = 
576
                        profile.getOperationTimings().get(SessionProfiler.SQL_GENERATION).toString();
563
                        profile.getOperationTimings().get(SessionProfiler.SqlGeneration).toString();
577
            } else {
564
            } else {
578
                items[12] = "";
565
                items[12] = "";
579
            }
566
            }
Lines 588-595 Link Here
588
     * @param profiles The new value for the property.
575
     * @param profiles The new value for the property.
589
     * @see #getProfiles
576
     * @see #getProfiles
590
     */
577
     */
591
    public void setProfiles(java.util.Vector profiles) {
578
    public void setProfiles(List<Profile> profiles) {
592
        java.util.Vector oldValue = fieldProfiles;
579
        List<Profile> oldValue = fieldProfiles;
593
        fieldProfiles = profiles;
580
        fieldProfiles = profiles;
594
        firePropertyChange("profiles", oldValue, profiles);
581
        firePropertyChange("profiles", oldValue, profiles);
595
582
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/config/ProfilerType.java (+1 lines)
Lines 29-34 Link Here
29
    //A tool used to provide high level performance profiling information
29
    //A tool used to provide high level performance profiling information
30
    public static final String PerformanceProfiler = "PerformanceProfiler";
30
    public static final String PerformanceProfiler = "PerformanceProfiler";
31
    public static final String QueryMonitor = "QueryMonitor";
31
    public static final String QueryMonitor = "QueryMonitor";
32
    public static final String PerformanceMonitor = "PerformanceMonitor";
32
    public static final String NoProfiler = "NoProfiler";
33
    public static final String NoProfiler = "NoProfiler";
33
34
34
    public static final String DEFAULT = NoProfiler;
35
    public static final String DEFAULT = NoProfiler;
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/DescriptorQueryManager.java (+1 lines)
Lines 819-824 Link Here
819
            readObjectQuery.setSelectionCriteria(getDescriptor().getObjectBuilder().getPrimaryKeyExpression());
819
            readObjectQuery.setSelectionCriteria(getDescriptor().getObjectBuilder().getPrimaryKeyExpression());
820
            setReadObjectQuery(readObjectQuery);
820
            setReadObjectQuery(readObjectQuery);
821
        }
821
        }
822
        getReadObjectQuery().setName("readObject");
822
823
823
        if (!hasInsertQuery()) {
824
        if (!hasInsertQuery()) {
824
            // Prepare insert query always.
825
            // Prepare insert query always.
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/eis/EISAccessor.java (-4 / +4 lines)
Lines 145-151 Link Here
145
                session.log(SessionLog.FINE, SessionLog.SQL, call.getLogString(this), (Object[])null, this, false);
145
                session.log(SessionLog.FINE, SessionLog.SQL, call.getLogString(this), (Object[])null, this, false);
146
            }
146
            }
147
            incrementCallCount(session);
147
            incrementCallCount(session);
148
            session.startOperationProfile(SessionProfiler.SQL_PREPARE, eisCall.getQuery(), SessionProfiler.ALL);
148
            session.startOperationProfile(SessionProfiler.SqlPrepare, eisCall.getQuery(), SessionProfiler.ALL);
149
            Record input = null;
149
            Record input = null;
150
            Record output = null;
150
            Record output = null;
151
            try {
151
            try {
Lines 153-161 Link Here
153
                input = getEISPlatform().createInputRecord(eisCall, this);
153
                input = getEISPlatform().createInputRecord(eisCall, this);
154
                output = getEISPlatform().createOutputRecord(eisCall, this);
154
                output = getEISPlatform().createOutputRecord(eisCall, this);
155
            } finally {
155
            } finally {
156
                session.endOperationProfile(SessionProfiler.SQL_PREPARE, eisCall.getQuery(), SessionProfiler.ALL);
156
                session.endOperationProfile(SessionProfiler.SqlPrepare, eisCall.getQuery(), SessionProfiler.ALL);
157
            }
157
            }
158
            session.startOperationProfile(SessionProfiler.STATEMENT_EXECUTE, eisCall.getQuery(), SessionProfiler.ALL);
158
            session.startOperationProfile(SessionProfiler.StatementExecute, eisCall.getQuery(), SessionProfiler.ALL);
159
            try {
159
            try {
160
                InteractionSpec interactionSpec = getEISPlatform().buildInteractionSpec(eisCall);
160
                InteractionSpec interactionSpec = getEISPlatform().buildInteractionSpec(eisCall);
161
                if (output == null) {
161
                if (output == null) {
Lines 183-189 Link Here
183
                }
183
                }
184
                session.log(SessionLog.FINEST, SessionLog.QUERY, "data_access_result", output);
184
                session.log(SessionLog.FINEST, SessionLog.QUERY, "data_access_result", output);
185
            } finally {
185
            } finally {
186
                session.endOperationProfile(SessionProfiler.STATEMENT_EXECUTE, eisCall.getQuery(), SessionProfiler.ALL);
186
                session.endOperationProfile(SessionProfiler.StatementExecute, eisCall.getQuery(), SessionProfiler.ALL);
187
            }
187
            }
188
        } catch (ResourceException exception) {
188
        } catch (ResourceException exception) {
189
            // Ensure each resource is released, but still ensure that the real exception is thrown.
189
            // Ensure each resource is released, but still ensure that the real exception is thrown.
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/DatabaseAccessor.java (-14 / +14 lines)
Lines 378-387 Link Here
378
378
379
        DatabaseQuery query = ((call == null)? null : call.getQuery());
379
        DatabaseQuery query = ((call == null)? null : call.getQuery());
380
        try {
380
        try {
381
            session.startOperationProfile(SessionProfiler.STATEMENT_EXECUTE, query, SessionProfiler.ALL);
381
            session.startOperationProfile(SessionProfiler.StatementExecute, query, SessionProfiler.ALL);
382
            statement.close();
382
            statement.close();
383
        } finally {
383
        } finally {
384
            session.endOperationProfile(SessionProfiler.STATEMENT_EXECUTE, query, SessionProfiler.ALL);
384
            session.endOperationProfile(SessionProfiler.StatementExecute, query, SessionProfiler.ALL);
385
            decrementCallCount();
385
            decrementCallCount();
386
            // If this is the cached dynamic statement, release it.
386
            // If this is the cached dynamic statement, release it.
387
            if (statement == this.dynamicStatement) {
387
            if (statement == this.dynamicStatement) {
Lines 571-581 Link Here
571
            if (session.shouldLog(SessionLog.FINE, SessionLog.SQL)) {// Avoid printing if no logging required.
571
            if (session.shouldLog(SessionLog.FINE, SessionLog.SQL)) {// Avoid printing if no logging required.
572
                session.log(SessionLog.FINE, SessionLog.SQL, dbCall.getLogString(this), (Object[])null, this, false);
572
                session.log(SessionLog.FINE, SessionLog.SQL, dbCall.getLogString(this), (Object[])null, this, false);
573
            }
573
            }
574
            session.startOperationProfile(SessionProfiler.SQL_PREPARE, dbCall.getQuery(), SessionProfiler.ALL);
574
            session.startOperationProfile(SessionProfiler.SqlPrepare, dbCall.getQuery(), SessionProfiler.ALL);
575
            try {
575
            try {
576
                statement = dbCall.prepareStatement(this, translationRow, session);
576
                statement = dbCall.prepareStatement(this, translationRow, session);
577
            } finally {
577
            } finally {
578
                session.endOperationProfile(SessionProfiler.SQL_PREPARE, dbCall.getQuery(), SessionProfiler.ALL);
578
                session.endOperationProfile(SessionProfiler.SqlPrepare, dbCall.getQuery(), SessionProfiler.ALL);
579
            }
579
            }
580
580
581
            // effectively this means that someone is executing an update type query.
581
            // effectively this means that someone is executing an update type query.
Lines 611-617 Link Here
611
                    return dbCall;
611
                    return dbCall;
612
                }
612
                }
613
613
614
                session.startOperationProfile(SessionProfiler.ROW_FETCH, dbCall.getQuery(), SessionProfiler.ALL);
614
                session.startOperationProfile(SessionProfiler.RowFetch, dbCall.getQuery(), SessionProfiler.ALL);
615
                try {
615
                try {
616
                    if (dbCall.isOneRowReturned()) {
616
                    if (dbCall.isOneRowReturned()) {
617
                        if (resultSet.next()) {
617
                        if (resultSet.next()) {
Lines 657-663 Link Here
657
                    }
657
                    }
658
                    resultSet.close();// This must be closed in case the statement is cached and not closed.
658
                    resultSet.close();// This must be closed in case the statement is cached and not closed.
659
                } finally {
659
                } finally {
660
                    session.endOperationProfile(SessionProfiler.ROW_FETCH, dbCall.getQuery(), SessionProfiler.ALL);
660
                    session.endOperationProfile(SessionProfiler.RowFetch, dbCall.getQuery(), SessionProfiler.ALL);
661
                }
661
                }
662
            }
662
            }
663
            // Log any warnings on finest.
663
            // Log any warnings on finest.
Lines 717-723 Link Here
717
        final ThreadCursoredList results = new ThreadCursoredList(20);
717
        final ThreadCursoredList results = new ThreadCursoredList(20);
718
        Thread thread = new Thread() {
718
        Thread thread = new Thread() {
719
            public void run() {
719
            public void run() {
720
                session.startOperationProfile(SessionProfiler.ROW_FETCH, dbCall.getQuery(), SessionProfiler.ALL);
720
                session.startOperationProfile(SessionProfiler.RowFetch, dbCall.getQuery(), SessionProfiler.ALL);
721
                try {
721
                try {
722
                    // Initial next was already validated before this method is called.
722
                    // Initial next was already validated before this method is called.
723
                    boolean hasNext = true;
723
                    boolean hasNext = true;
Lines 748-754 Link Here
748
                    }
748
                    }
749
                    results.throwException(exception);
749
                    results.throwException(exception);
750
                } finally {
750
                } finally {
751
                    session.endOperationProfile(SessionProfiler.ROW_FETCH, dbCall.getQuery(), SessionProfiler.ALL);
751
                    session.endOperationProfile(SessionProfiler.RowFetch, dbCall.getQuery(), SessionProfiler.ALL);
752
                }
752
                }
753
753
754
                // This is in a separate try block to ensure that the real exception is not masked by the close exception.
754
                // This is in a separate try block to ensure that the real exception is not masked by the close exception.
Lines 778-786 Link Here
778
778
779
        try {
779
        try {
780
            if (call != null) {
780
            if (call != null) {
781
                session.startOperationProfile(SessionProfiler.STATEMENT_EXECUTE, call.getQuery(), SessionProfiler.ALL);
781
                session.startOperationProfile(SessionProfiler.StatementExecute, call.getQuery(), SessionProfiler.ALL);
782
            } else {
782
            } else {
783
                session.startOperationProfile(SessionProfiler.STATEMENT_EXECUTE, null, SessionProfiler.ALL);                
783
                session.startOperationProfile(SessionProfiler.StatementExecute, null, SessionProfiler.ALL);                
784
            }
784
            }
785
            if ((call != null) && call.isDynamicCall(session)) {
785
            if ((call != null) && call.isDynamicCall(session)) {
786
                rowCount = statement.executeUpdate(call.getSQLString());
786
                rowCount = statement.executeUpdate(call.getSQLString());
Lines 798-806 Link Here
798
            }
798
            }
799
        } finally {
799
        } finally {
800
            if (call != null) {
800
            if (call != null) {
801
                session.endOperationProfile(SessionProfiler.STATEMENT_EXECUTE, call.getQuery(), SessionProfiler.ALL);
801
                session.endOperationProfile(SessionProfiler.StatementExecute, call.getQuery(), SessionProfiler.ALL);
802
            } else {
802
            } else {
803
                session.endOperationProfile(SessionProfiler.STATEMENT_EXECUTE, null, SessionProfiler.ALL);                
803
                session.endOperationProfile(SessionProfiler.StatementExecute, null, SessionProfiler.ALL);                
804
            }
804
            }
805
        }
805
        }
806
806
Lines 880-886 Link Here
880
    public ResultSet executeSelect(DatabaseCall call, Statement statement, AbstractSession session) throws SQLException {
880
    public ResultSet executeSelect(DatabaseCall call, Statement statement, AbstractSession session) throws SQLException {
881
        ResultSet resultSet;
881
        ResultSet resultSet;
882
882
883
        session.startOperationProfile(SessionProfiler.STATEMENT_EXECUTE, call.getQuery(), SessionProfiler.ALL);
883
        session.startOperationProfile(SessionProfiler.StatementExecute, call.getQuery(), SessionProfiler.ALL);
884
        try {
884
        try {
885
            if (call.isDynamicCall(session)) {
885
            if (call.isDynamicCall(session)) {
886
                resultSet = statement.executeQuery(call.getSQLString());
886
                resultSet = statement.executeQuery(call.getSQLString());
Lines 888-894 Link Here
888
                resultSet = ((PreparedStatement)statement).executeQuery();
888
                resultSet = ((PreparedStatement)statement).executeQuery();
889
            }
889
            }
890
        } finally {
890
        } finally {
891
            session.endOperationProfile(SessionProfiler.STATEMENT_EXECUTE, call.getQuery(), SessionProfiler.ALL);
891
            session.endOperationProfile(SessionProfiler.StatementExecute, call.getQuery(), SessionProfiler.ALL);
892
        }
892
        }
893
893
894
        // Allow for procs with outputs to be raised as events for error handling.
894
        // Allow for procs with outputs to be raised as events for error handling.
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/DatabasePlatform.java (-2 / +2 lines)
Lines 1433-1439 Link Here
1433
        Object result = null;
1433
        Object result = null;
1434
        ResultSetMetaData metaData = resultSet.getMetaData();
1434
        ResultSetMetaData metaData = resultSet.getMetaData();
1435
1435
1436
        session.startOperationProfile(SessionProfiler.ROW_FETCH, dbCall.getQuery(), SessionProfiler.ALL);
1436
        session.startOperationProfile(SessionProfiler.RowFetch, dbCall.getQuery(), SessionProfiler.ALL);
1437
        try {
1437
        try {
1438
            if (dbCall.isOneRowReturned()) {
1438
            if (dbCall.isOneRowReturned()) {
1439
                if (resultSet.next()) {
1439
                if (resultSet.next()) {
Lines 1456-1462 Link Here
1456
            }
1456
            }
1457
            resultSet.close();// This must be closed incase the statement is cached and not closed.
1457
            resultSet.close();// This must be closed incase the statement is cached and not closed.
1458
        } finally {
1458
        } finally {
1459
            session.endOperationProfile(SessionProfiler.ROW_FETCH, dbCall.getQuery(), SessionProfiler.ALL);
1459
            session.endOperationProfile(SessionProfiler.RowFetch, dbCall.getQuery(), SessionProfiler.ALL);
1460
        }
1460
        }
1461
        return result;
1461
        return result;
1462
    }
1462
    }
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/DatasourceAccessor.java (-19 / +25 lines)
Lines 231-243 Link Here
231
        session.log(SessionLog.FINER, SessionLog.TRANSACTION, "begin_transaction", (Object[])null, this);
231
        session.log(SessionLog.FINER, SessionLog.TRANSACTION, "begin_transaction", (Object[])null, this);
232
232
233
        try {
233
        try {
234
            session.startOperationProfile(SessionProfiler.TRANSACTION);
234
            session.startOperationProfile(SessionProfiler.Transaction);
235
            incrementCallCount(session);
235
            incrementCallCount(session);
236
            basicBeginTransaction(session);
236
            basicBeginTransaction(session);
237
            this.isInTransaction = true;
237
            this.isInTransaction = true;
238
        } finally {
238
        } finally {
239
            decrementCallCount();
239
            decrementCallCount();
240
            session.endOperationProfile(SessionProfiler.TRANSACTION);
240
            session.endOperationProfile(SessionProfiler.Transaction);
241
        }
241
        }
242
    }
242
    }
243
243
Lines 381-387 Link Here
381
        session.log(SessionLog.FINER, SessionLog.TRANSACTION, "commit_transaction", (Object[])null, this);
381
        session.log(SessionLog.FINER, SessionLog.TRANSACTION, "commit_transaction", (Object[])null, this);
382
382
383
        try {
383
        try {
384
            session.startOperationProfile(SessionProfiler.TRANSACTION);
384
            session.startOperationProfile(SessionProfiler.Transaction);
385
            incrementCallCount(session);
385
            incrementCallCount(session);
386
            basicCommitTransaction(session);
386
            basicCommitTransaction(session);
387
387
Lines 392-398 Link Here
392
        } finally {
392
        } finally {
393
            sequencingCallback = null;
393
            sequencingCallback = null;
394
            decrementCallCount();
394
            decrementCallCount();
395
            session.endOperationProfile(SessionProfiler.TRANSACTION);
395
            session.endOperationProfile(SessionProfiler.Transaction);
396
        }
396
        }
397
    }
397
    }
398
398
Lines 401-408 Link Here
401
     * Catch exceptions and re-throw as EclipseLink exceptions.
401
     * Catch exceptions and re-throw as EclipseLink exceptions.
402
     */
402
     */
403
    public void connect(Login login, AbstractSession session) throws DatabaseException {
403
    public void connect(Login login, AbstractSession session) throws DatabaseException {
404
        session.startOperationProfile(SessionProfiler.CONNECT);
404
        session.startOperationProfile(SessionProfiler.ConnectionManagement);
405
        session.incrementProfile(SessionProfiler.TlConnects);
405
        session.incrementProfile(SessionProfiler.Connects);
406
406
407
        try {
407
        try {
408
            if (session.shouldLog(SessionLog.CONFIG, SessionLog.CONNECTION)) {// Avoid printing if no logging required.
408
            if (session.shouldLog(SessionLog.CONFIG, SessionLog.CONNECTION)) {// Avoid printing if no logging required.
Lines 427-433 Link Here
427
                decrementCallCount();
427
                decrementCallCount();
428
            }
428
            }
429
        } finally {
429
        } finally {
430
            session.endOperationProfile(SessionProfiler.CONNECT);
430
            session.endOperationProfile(SessionProfiler.ConnectionManagement);
431
        }
431
        }
432
    }
432
    }
433
433
Lines 471-483 Link Here
471
        if (this.datasourceConnection == null) {
471
        if (this.datasourceConnection == null) {
472
            return;
472
            return;
473
        }
473
        }
474
        session.incrementProfile(SessionProfiler.TlDisconnects);
474
        session.incrementProfile(SessionProfiler.Disconnects);
475
        session.startOperationProfile(SessionProfiler.CONNECT);
475
        session.startOperationProfile(SessionProfiler.ConnectionManagement);
476
        releaseCustomizer();
476
        try {
477
        closeDatasourceConnection();
477
            releaseCustomizer();
478
        this.datasourceConnection = null;
478
            closeDatasourceConnection();
479
        this.isInTransaction = true;
479
            this.datasourceConnection = null;
480
        session.endOperationProfile(SessionProfiler.CONNECT);
480
            this.isInTransaction = true;
481
        } finally {
482
            session.endOperationProfile(SessionProfiler.ConnectionManagement);
483
        }
481
    }
484
    }
482
485
483
    /**
486
    /**
Lines 554-562 Link Here
554
     */
557
     */
555
    protected void reconnect(AbstractSession session) throws DatabaseException {
558
    protected void reconnect(AbstractSession session) throws DatabaseException {
556
        session.log(SessionLog.FINEST, SessionLog.CONNECTION, "reconnecting_to_external_connection_pool");
559
        session.log(SessionLog.FINEST, SessionLog.CONNECTION, "reconnecting_to_external_connection_pool");
557
        session.startOperationProfile(SessionProfiler.CONNECT);
560
        session.startOperationProfile(SessionProfiler.ConnectionManagement);
558
        connectInternal(this.login, session);
561
        try {
559
        session.endOperationProfile(SessionProfiler.CONNECT);
562
            connectInternal(this.login, session);
563
        } finally {
564
            session.endOperationProfile(SessionProfiler.ConnectionManagement);
565
        }
560
    }
566
    }
561
567
562
    /**
568
    /**
Lines 658-671 Link Here
658
        session.log(SessionLog.FINER, SessionLog.TRANSACTION, "rollback_transaction", (Object[])null, this);
664
        session.log(SessionLog.FINER, SessionLog.TRANSACTION, "rollback_transaction", (Object[])null, this);
659
665
660
        try {
666
        try {
661
            session.startOperationProfile(SessionProfiler.TRANSACTION);
667
            session.startOperationProfile(SessionProfiler.Transaction);
662
            incrementCallCount(session);
668
            incrementCallCount(session);
663
            basicRollbackTransaction(session);
669
            basicRollbackTransaction(session);
664
        } finally {
670
        } finally {
665
            this.isInTransaction = false;
671
            this.isInTransaction = false;
666
            sequencingCallback = null;
672
            sequencingCallback = null;
667
            decrementCallCount();
673
            decrementCallCount();
668
            session.endOperationProfile(SessionProfiler.TRANSACTION);
674
            session.endOperationProfile(SessionProfiler.Transaction);
669
        }
675
        }
670
    }
676
    }
671
677
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/DynamicSQLBatchWritingMechanism.java (-4 / +4 lines)
Lines 185-195 Link Here
185
        writer.write(platform.getBatchEndString());
185
        writer.write(platform.getBatchEndString());
186
186
187
        try {
187
        try {
188
            session.startOperationProfile(SessionProfiler.SQL_PREPARE, null, SessionProfiler.ALL);
188
            session.startOperationProfile(SessionProfiler.SqlPrepare, null, SessionProfiler.ALL);
189
            try {
189
            try {
190
                statement = this.databaseAccessor.getConnection().prepareStatement(writer.toString());
190
                statement = this.databaseAccessor.getConnection().prepareStatement(writer.toString());
191
            } finally {
191
            } finally {
192
                session.endOperationProfile(SessionProfiler.SQL_PREPARE, null, SessionProfiler.ALL);
192
                session.endOperationProfile(SessionProfiler.SqlPrepare, null, SessionProfiler.ALL);
193
            }
193
            }
194
        } catch (SQLException exception) {
194
        } catch (SQLException exception) {
195
            //If this is a connection from an external pool then closeStatement will close the connection.
195
            //If this is a connection from an external pool then closeStatement will close the connection.
Lines 221-227 Link Here
221
        Statement statement = null;
221
        Statement statement = null;
222
222
223
        try {
223
        try {
224
            session.startOperationProfile(SessionProfiler.SQL_PREPARE, null, SessionProfiler.ALL);
224
            session.startOperationProfile(SessionProfiler.SqlPrepare, null, SessionProfiler.ALL);
225
            try {
225
            try {
226
                statement = this.databaseAccessor.getConnection().createStatement();
226
                statement = this.databaseAccessor.getConnection().createStatement();
227
                for (Iterator sqlStringsIterator = this.sqlStrings.iterator();
227
                for (Iterator sqlStringsIterator = this.sqlStrings.iterator();
Lines 233-239 Link Here
233
                	statement.setQueryTimeout(queryTimeoutCache);
233
                	statement.setQueryTimeout(queryTimeoutCache);
234
                }
234
                }
235
            } finally {
235
            } finally {
236
                session.endOperationProfile(SessionProfiler.SQL_PREPARE, null, SessionProfiler.ALL);
236
                session.endOperationProfile(SessionProfiler.SqlPrepare, null, SessionProfiler.ALL);
237
            }
237
            }
238
        } catch (SQLException exception) {
238
        } catch (SQLException exception) {
239
            //If this is a connection from an external pool then closeStatement will close the connection.
239
            //If this is a connection from an external pool then closeStatement will close the connection.
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/ParameterizedSQLBatchWritingMechanism.java (-2 / +2 lines)
Lines 166-172 Link Here
166
        PreparedStatement statement = null;
166
        PreparedStatement statement = null;
167
167
168
        try {
168
        try {
169
            session.startOperationProfile(SessionProfiler.SQL_PREPARE, null, SessionProfiler.ALL);
169
            session.startOperationProfile(SessionProfiler.SqlPrepare, null, SessionProfiler.ALL);
170
            try {
170
            try {
171
                boolean shouldUnwrapConnection = session.getPlatform().usesNativeBatchWriting();
171
                boolean shouldUnwrapConnection = session.getPlatform().usesNativeBatchWriting();
172
                statement = (PreparedStatement)this.databaseAccessor.prepareStatement(this.previousCall, session, shouldUnwrapConnection);
172
                statement = (PreparedStatement)this.databaseAccessor.prepareStatement(this.previousCall, session, shouldUnwrapConnection);
Lines 191-197 Link Here
191
                    executionCount += this.databaseAccessor.getPlatform().addBatch(statement);
191
                    executionCount += this.databaseAccessor.getPlatform().addBatch(statement);
192
                }
192
                }
193
            } finally {
193
            } finally {
194
                session.endOperationProfile(SessionProfiler.SQL_PREPARE, null, SessionProfiler.ALL);
194
                session.endOperationProfile(SessionProfiler.SqlPrepare, null, SessionProfiler.ALL);
195
            }
195
            }
196
        } catch (SQLException exception) {
196
        } catch (SQLException exception) {
197
            // If this is a connection from an external pool then closeStatement will close the connection.
197
            // If this is a connection from an external pool then closeStatement will close the connection.
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/descriptors/ObjectBuilder.java (-34 / +27 lines)
Lines 461-501 Link Here
461
    public Object buildObject(ObjectBuildingQuery query, AbstractRecord databaseRow, JoinedAttributeManager joinManager) throws DatabaseException, QueryException {
461
    public Object buildObject(ObjectBuildingQuery query, AbstractRecord databaseRow, JoinedAttributeManager joinManager) throws DatabaseException, QueryException {
462
        // Profile object building.
462
        // Profile object building.
463
        AbstractSession session = query.getSession();
463
        AbstractSession session = query.getSession();
464
        session.startOperationProfile(SessionProfiler.OBJECT_BUILDING, query, SessionProfiler.ALL);
464
        session.startOperationProfile(SessionProfiler.ObjectBuilding, query, SessionProfiler.ALL);
465
466
        Object primaryKey = extractPrimaryKeyFromRow(databaseRow, session);
467
468
        // Check for null primary key, this is not allowed.
469
        if ((primaryKey == null) && (!query.hasPartialAttributeExpressions()) && (!this.descriptor.isAggregateCollectionDescriptor())) {
470
            // Profile object building.
471
            session.endOperationProfile(SessionProfiler.OBJECT_BUILDING, query, SessionProfiler.ALL);
472
473
            //BUG 3168689: EJBQL: "Select Distinct s.customer from SpouseBean s"
474
            //BUG 3168699: EJBQL: "Select s.customer from SpouseBean s where s.id = '6'"
475
            //If we return either a single null, or a Collection containing at least 
476
            //one null, then we want the nulls returned/included if the indicated 
477
            //property is set in the query. (As opposed to throwing an Exception).
478
            if (query.shouldBuildNullForNullPk()) {
479
                return null;
480
            } else {
481
                throw QueryException.nullPrimaryKeyInBuildingObject(query, databaseRow);
482
            }
483
        }
484
        ClassDescriptor concreteDescriptor = this.descriptor;
485
        if (concreteDescriptor.hasInheritance() && concreteDescriptor.getInheritancePolicy().shouldReadSubclasses()) {
486
            Class classValue = concreteDescriptor.getInheritancePolicy().classFromRow(databaseRow, session);
487
            concreteDescriptor = concreteDescriptor.getInheritancePolicy().getDescriptor(classValue);
488
            if ((concreteDescriptor == null) && query.hasPartialAttributeExpressions()) {
489
                concreteDescriptor = this.descriptor;
490
            }
491
            if (concreteDescriptor == null) {
492
                // Profile object building.
493
                session.endOperationProfile(SessionProfiler.OBJECT_BUILDING, query, SessionProfiler.ALL);
494
                throw QueryException.noDescriptorForClassFromInheritancePolicy(query, classValue);
495
            }
496
        }
497
        Object domainObject = null;
465
        Object domainObject = null;
498
        try {
466
        try {
467
            Object primaryKey = extractPrimaryKeyFromRow(databaseRow, session);
468
            // Check for null primary key, this is not allowed.
469
            if ((primaryKey == null) && (!query.hasPartialAttributeExpressions()) && (!this.descriptor.isAggregateCollectionDescriptor())) {
470
                //BUG 3168689: EJBQL: "Select Distinct s.customer from SpouseBean s"
471
                //BUG 3168699: EJBQL: "Select s.customer from SpouseBean s where s.id = '6'"
472
                //If we return either a single null, or a Collection containing at least 
473
                //one null, then we want the nulls returned/included if the indicated 
474
                //property is set in the query. (As opposed to throwing an Exception).
475
                if (query.shouldBuildNullForNullPk()) {
476
                    return null;
477
                } else {
478
                    throw QueryException.nullPrimaryKeyInBuildingObject(query, databaseRow);
479
                }
480
            }
481
            ClassDescriptor concreteDescriptor = this.descriptor;
482
            if (concreteDescriptor.hasInheritance() && concreteDescriptor.getInheritancePolicy().shouldReadSubclasses()) {
483
                Class classValue = concreteDescriptor.getInheritancePolicy().classFromRow(databaseRow, session);
484
                concreteDescriptor = concreteDescriptor.getInheritancePolicy().getDescriptor(classValue);
485
                if ((concreteDescriptor == null) && query.hasPartialAttributeExpressions()) {
486
                    concreteDescriptor = this.descriptor;
487
                }
488
                if (concreteDescriptor == null) {
489
                    throw QueryException.noDescriptorForClassFromInheritancePolicy(query, classValue);
490
                }
491
            }
499
            if (session.isUnitOfWork()) {
492
            if (session.isUnitOfWork()) {
500
                // Do not wrap yet if in UnitOfWork, as there is still much more
493
                // Do not wrap yet if in UnitOfWork, as there is still much more
501
                // processing ahead.
494
                // processing ahead.
Lines 512-518 Link Here
512
                }
505
                }
513
            }
506
            }
514
        } finally {
507
        } finally {
515
            session.endOperationProfile(SessionProfiler.OBJECT_BUILDING, query, SessionProfiler.ALL);
508
            session.endOperationProfile(SessionProfiler.ObjectBuilding, query, SessionProfiler.ALL);
516
        }
509
        }
517
        return domainObject;
510
        return domainObject;
518
    }
511
    }
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/identitymaps/IdentityMapManager.java (-64 / +64 lines)
Lines 50-55 Link Here
50
 * @since TOPLink/Java 1.0
50
 * @since TOPLink/Java 1.0
51
 */
51
 */
52
public class IdentityMapManager implements Serializable, Cloneable {
52
public class IdentityMapManager implements Serializable, Cloneable {
53
    protected static final String MONITOR_PREFIX = "Info:Cache:";
53
54
54
    /** A table of identity maps with the key being the domain Class. */
55
    /** A table of identity maps with the key being the domain Class. */
55
    protected Map<Class, IdentityMap> identityMaps;
56
    protected Map<Class, IdentityMap> identityMaps;
Lines 94-107 Link Here
94
    public CacheKey acquireDeferredLock(Object primaryKey, Class domainClass, ClassDescriptor descriptor) {
95
    public CacheKey acquireDeferredLock(Object primaryKey, Class domainClass, ClassDescriptor descriptor) {
95
        CacheKey cacheKey = null;
96
        CacheKey cacheKey = null;
96
        if (this.isCacheAccessPreCheckRequired) {
97
        if (this.isCacheAccessPreCheckRequired) {
97
            this.session.startOperationProfile(SessionProfiler.CACHE);
98
            this.session.startOperationProfile(SessionProfiler.Caching);
98
            acquireReadLock();
99
            acquireReadLock();
100
            IdentityMap identityMap = getIdentityMap(descriptor, false);
99
            try {
101
            try {
100
                cacheKey = getIdentityMap(descriptor, false).acquireDeferredLock(primaryKey);
102
                cacheKey = identityMap.acquireDeferredLock(primaryKey);
101
            } finally {
103
            } finally {
102
                releaseReadLock();
104
                releaseReadLock();
103
            }
105
            }
104
            this.session.endOperationProfile(SessionProfiler.CACHE);
106
            this.session.endOperationProfile(SessionProfiler.Caching);
107
            if (cacheKey.getObject() == null) {
108
                this.session.updateProfile(MONITOR_PREFIX + domainClass.getSimpleName(), identityMap.getSize());
109
            }
105
        } else {
110
        } else {
106
            cacheKey = getIdentityMap(descriptor, false).acquireDeferredLock(primaryKey);
111
            cacheKey = getIdentityMap(descriptor, false).acquireDeferredLock(primaryKey);
107
        }
112
        }
Lines 121-134 Link Here
121
        }
126
        }
122
        CacheKey cacheKey = null;
127
        CacheKey cacheKey = null;
123
        if (this.isCacheAccessPreCheckRequired) {
128
        if (this.isCacheAccessPreCheckRequired) {
124
            this.session.startOperationProfile(SessionProfiler.CACHE);
129
            this.session.startOperationProfile(SessionProfiler.Caching);
125
            acquireReadLock();
130
            acquireReadLock();
131
            IdentityMap identityMap = getIdentityMap(descriptor, false);
126
            try {
132
            try {
127
                cacheKey = getIdentityMap(descriptor, false).acquireLock(primaryKey, forMerge);
133
                cacheKey = identityMap.acquireLock(primaryKey, forMerge);
128
            } finally {
134
            } finally {
129
                releaseReadLock();
135
                releaseReadLock();
130
            }
136
            }
131
            this.session.endOperationProfile(SessionProfiler.CACHE);
137
            this.session.endOperationProfile(SessionProfiler.Caching);
138
            if (cacheKey.getObject() == null) {
139
                this.session.updateProfile(MONITOR_PREFIX + domainClass.getSimpleName(), identityMap.getSize());
140
            }
132
        } else {
141
        } else {
133
            cacheKey = getIdentityMap(descriptor, false).acquireLock(primaryKey, forMerge);
142
            cacheKey = getIdentityMap(descriptor, false).acquireLock(primaryKey, forMerge);
134
        }
143
        }
Lines 148-161 Link Here
148
        }
157
        }
149
        CacheKey cacheKey = null;
158
        CacheKey cacheKey = null;
150
        if (this.isCacheAccessPreCheckRequired) {
159
        if (this.isCacheAccessPreCheckRequired) {
151
            this.session.startOperationProfile(SessionProfiler.CACHE);
160
            this.session.startOperationProfile(SessionProfiler.Caching);
152
            acquireReadLock();
161
            acquireReadLock();
162
            IdentityMap identityMap = getIdentityMap(descriptor, false);
153
            try {
163
            try {
154
                cacheKey = getIdentityMap(descriptor, false).acquireLockNoWait(primaryKey, forMerge);
164
                cacheKey = identityMap.acquireLockNoWait(primaryKey, forMerge);
155
            } finally {
165
            } finally {
156
                releaseReadLock();
166
                releaseReadLock();
157
            }
167
            }
158
            this.session.endOperationProfile(SessionProfiler.CACHE);
168
            this.session.endOperationProfile(SessionProfiler.Caching);
169
            if (cacheKey.getObject() == null) {
170
                this.session.updateProfile(MONITOR_PREFIX + domainClass.getSimpleName(), identityMap.getSize());
171
            }
159
        } else {
172
        } else {
160
            cacheKey = getIdentityMap(descriptor, false).acquireLockNoWait(primaryKey, forMerge);
173
            cacheKey = getIdentityMap(descriptor, false).acquireLockNoWait(primaryKey, forMerge);
161
        }
174
        }
Lines 175-188 Link Here
175
        }
188
        }
176
        CacheKey cacheKey = null;
189
        CacheKey cacheKey = null;
177
        if (this.isCacheAccessPreCheckRequired) {
190
        if (this.isCacheAccessPreCheckRequired) {
178
            this.session.startOperationProfile(SessionProfiler.CACHE);
191
            this.session.startOperationProfile(SessionProfiler.Caching);
179
            acquireReadLock();
192
            acquireReadLock();
193
            IdentityMap identityMap = getIdentityMap(descriptor, false);
180
            try {
194
            try {
181
                cacheKey = getIdentityMap(descriptor, false).acquireLockWithWait(primaryKey, forMerge, wait);
195
                cacheKey = identityMap.acquireLockWithWait(primaryKey, forMerge, wait);
182
            } finally {
196
            } finally {
183
                releaseReadLock();
197
                releaseReadLock();
184
            }
198
            }
185
            this.session.endOperationProfile(SessionProfiler.CACHE);
199
            this.session.endOperationProfile(SessionProfiler.Caching);
200
            if (cacheKey.getObject() == null) {
201
                this.session.updateProfile(MONITOR_PREFIX + domainClass.getSimpleName(), identityMap.getSize());
202
            }
186
        } else {
203
        } else {
187
            cacheKey = getIdentityMap(descriptor, false).acquireLockWithWait(primaryKey, forMerge, wait);
204
            cacheKey = getIdentityMap(descriptor, false).acquireLockWithWait(primaryKey, forMerge, wait);
188
        }
205
        }
Lines 207-219 Link Here
207
     * Provides access for setting a concurrency lock on an IdentityMap.
224
     * Provides access for setting a concurrency lock on an IdentityMap.
208
     */
225
     */
209
    public void acquireReadLock() {
226
    public void acquireReadLock() {
210
        this.session.startOperationProfile(SessionProfiler.CACHE);
227
        this.session.startOperationProfile(SessionProfiler.Caching);
211
228
212
        if (this.session.getDatasourceLogin().shouldSynchronizedReadOnWrite()) {
229
        if (this.session.getDatasourceLogin().shouldSynchronizedReadOnWrite()) {
213
            getCacheMutex().acquireReadLock();
230
            getCacheMutex().acquireReadLock();
214
        }
231
        }
215
232
216
        this.session.endOperationProfile(SessionProfiler.CACHE);
233
        this.session.endOperationProfile(SessionProfiler.Caching);
217
    }
234
    }
218
235
219
    /**
236
    /**
Lines 230-243 Link Here
230
        }
247
        }
231
        CacheKey cacheKey = null;
248
        CacheKey cacheKey = null;
232
        if (this.isCacheAccessPreCheckRequired) {
249
        if (this.isCacheAccessPreCheckRequired) {
233
            this.session.startOperationProfile(SessionProfiler.CACHE);
250
            this.session.startOperationProfile(SessionProfiler.Caching);
234
            acquireReadLock();
251
            acquireReadLock();
235
            try {
252
            try {
236
                cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKey(primaryKey);
253
                cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKey(primaryKey);
237
            } finally {
254
            } finally {
238
                releaseReadLock();
255
                releaseReadLock();
239
            }
256
            }
240
            this.session.endOperationProfile(SessionProfiler.CACHE);
257
            this.session.endOperationProfile(SessionProfiler.Caching);
241
        } else {
258
        } else {
242
            cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKey(primaryKey);
259
            cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKey(primaryKey);
243
        }
260
        }
Lines 260-273 Link Here
260
        }
277
        }
261
        CacheKey cacheKey = null;
278
        CacheKey cacheKey = null;
262
        if (this.isCacheAccessPreCheckRequired) {
279
        if (this.isCacheAccessPreCheckRequired) {
263
            this.session.startOperationProfile(SessionProfiler.CACHE);
280
            this.session.startOperationProfile(SessionProfiler.Caching);
264
            acquireReadLock();
281
            acquireReadLock();
265
            try {
282
            try {
266
                cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKeyNoWait(primaryKey);
283
                cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKeyNoWait(primaryKey);
267
            } finally {
284
            } finally {
268
                releaseReadLock();
285
                releaseReadLock();
269
            }
286
            }
270
            this.session.endOperationProfile(SessionProfiler.CACHE);
287
            this.session.endOperationProfile(SessionProfiler.Caching);
271
        } else {
288
        } else {
272
            cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKeyNoWait(primaryKey);
289
            cacheKey = getIdentityMap(descriptor, false).acquireReadLockOnCacheKeyNoWait(primaryKey);
273
        }
290
        }
Lines 427-439 Link Here
427
            return false;
444
            return false;
428
        }
445
        }
429
        if (this.isCacheAccessPreCheckRequired) {
446
        if (this.isCacheAccessPreCheckRequired) {
430
            this.session.startOperationProfile(SessionProfiler.CACHE);
447
            this.session.startOperationProfile(SessionProfiler.Caching);
431
            acquireReadLock();
448
            acquireReadLock();
432
            try {
449
            try {
433
                return map.containsKey(key);
450
                return map.containsKey(key);
434
            } finally {
451
            } finally {
435
                releaseReadLock();
452
                releaseReadLock();
436
                this.session.endOperationProfile(SessionProfiler.CACHE);
453
                this.session.endOperationProfile(SessionProfiler.Caching);
437
            }
454
            }
438
        } else {
455
        } else {
439
            return map.containsKey(key);
456
            return map.containsKey(key);
Lines 445-451 Link Here
445
     */
462
     */
446
    public Vector getAllFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, int valueHolderPolicy, boolean shouldReturnInvalidatedObjects) {
463
    public Vector getAllFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, int valueHolderPolicy, boolean shouldReturnInvalidatedObjects) {
447
        ClassDescriptor descriptor = this.session.getDescriptor(theClass);
464
        ClassDescriptor descriptor = this.session.getDescriptor(theClass);
448
        this.session.startOperationProfile(SessionProfiler.CACHE);
465
        this.session.startOperationProfile(SessionProfiler.Caching);
449
        Vector objects = null;
466
        Vector objects = null;
450
        try {
467
        try {
451
            if (selectionCriteria != null) {
468
            if (selectionCriteria != null) {
Lines 477-494 Link Here
477
                if ((object.getClass() == theClass) || (theClass.isInstance(object))) {
494
                if ((object.getClass() == theClass) || (theClass.isInstance(object))) {
478
                    if (selectionCriteria == null) {
495
                    if (selectionCriteria == null) {
479
                        objects.add(object);
496
                        objects.add(object);
480
                        this.session.incrementProfile(SessionProfiler.CacheHits);
481
                    } else {
497
                    } else {
482
                        try {
498
                        try {
483
                            if (selectionCriteria.doesConform(object, this.session, (AbstractRecord)translationRow, valueHolderPolicy)) {
499
                            if (selectionCriteria.doesConform(object, this.session, (AbstractRecord)translationRow, valueHolderPolicy)) {
484
                                objects.addElement(object);
500
                                objects.add(object);
485
                                this.session.incrementProfile(SessionProfiler.CacheHits);
486
                            }
501
                            }
487
                        } catch (QueryException queryException) {
502
                        } catch (QueryException queryException) {
488
                            if (queryException.getErrorCode() == QueryException.MUST_INSTANTIATE_VALUEHOLDERS) {
503
                            if (queryException.getErrorCode() == QueryException.MUST_INSTANTIATE_VALUEHOLDERS) {
489
                                if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED) {
504
                                if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED) {
490
                                    objects.add(object);
505
                                    objects.add(object);
491
                                    this.session.incrementProfile(SessionProfiler.CacheHits);
492
                                } else if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_THROW_INDIRECTION_EXCEPTION) {
506
                                } else if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_THROW_INDIRECTION_EXCEPTION) {
493
                                    throw queryException;
507
                                    throw queryException;
494
                                }
508
                                }
Lines 500-506 Link Here
500
                }
514
                }
501
            }
515
            }
502
        } finally {
516
        } finally {
503
            this.session.endOperationProfile(SessionProfiler.CACHE);
517
            this.session.endOperationProfile(SessionProfiler.Caching);
504
        }
518
        }
505
        return objects;
519
        return objects;
506
    }
520
    }
Lines 510-516 Link Here
510
     */
524
     */
511
    public void invalidateObjects(Expression selectionCriteria, Class theClass, Record translationRow, boolean shouldInvalidateOnException) {
525
    public void invalidateObjects(Expression selectionCriteria, Class theClass, Record translationRow, boolean shouldInvalidateOnException) {
512
        ClassDescriptor descriptor = this.session.getDescriptor(theClass);
526
        ClassDescriptor descriptor = this.session.getDescriptor(theClass);
513
        this.session.startOperationProfile(SessionProfiler.CACHE);
527
        this.session.startOperationProfile(SessionProfiler.Caching);
514
        try {
528
        try {
515
            IdentityMap map = getIdentityMap(descriptor, true);
529
            IdentityMap map = getIdentityMap(descriptor, true);
516
            if(map == null) {
530
            if(map == null) {
Lines 591-597 Link Here
591
                }
605
                }
592
            }
606
            }
593
        } finally {
607
        } finally {
594
            this.session.endOperationProfile(SessionProfiler.CACHE);
608
            this.session.endOperationProfile(SessionProfiler.Caching);
595
        }
609
        }
596
    }
610
    }
597
611
Lines 608-620 Link Here
608
        }
622
        }
609
        CacheKey cacheKey = null;
623
        CacheKey cacheKey = null;
610
        if (this.isCacheAccessPreCheckRequired) {
624
        if (this.isCacheAccessPreCheckRequired) {
611
            this.session.startOperationProfile(SessionProfiler.CACHE);
625
            this.session.startOperationProfile(SessionProfiler.Caching);
612
            acquireReadLock();
626
            acquireReadLock();
613
            try {
627
            try {
614
                cacheKey = map.getCacheKeyForLock(primaryKey);
628
                cacheKey = map.getCacheKeyForLock(primaryKey);
615
            } finally {
629
            } finally {
616
                releaseReadLock();
630
                releaseReadLock();
617
                this.session.endOperationProfile(SessionProfiler.CACHE);
631
                this.session.endOperationProfile(SessionProfiler.Caching);
618
            }
632
            }
619
        } else {
633
        } else {
620
            cacheKey = map.getCacheKeyForLock(primaryKey);
634
            cacheKey = map.getCacheKeyForLock(primaryKey);
Lines 635-647 Link Here
635
        }
649
        }
636
        CacheKey cacheKey = null;
650
        CacheKey cacheKey = null;
637
        if (this.isCacheAccessPreCheckRequired) {
651
        if (this.isCacheAccessPreCheckRequired) {
638
            this.session.startOperationProfile(SessionProfiler.CACHE);
652
            this.session.startOperationProfile(SessionProfiler.Caching);
639
            acquireReadLock();
653
            acquireReadLock();
640
            try {
654
            try {
641
                cacheKey = map.getCacheKey(primaryKey);
655
                cacheKey = map.getCacheKey(primaryKey);
642
            } finally {
656
            } finally {
643
                releaseReadLock();
657
                releaseReadLock();
644
                this.session.endOperationProfile(SessionProfiler.CACHE);
658
                this.session.endOperationProfile(SessionProfiler.Caching);
645
            }
659
            }
646
        } else {
660
        } else {
647
            cacheKey = map.getCacheKey(primaryKey);
661
            cacheKey = map.getCacheKey(primaryKey);
Lines 702-708 Link Here
702
        }
716
        }
703
        Object domainObject = null;
717
        Object domainObject = null;
704
        if (this.isCacheAccessPreCheckRequired) {
718
        if (this.isCacheAccessPreCheckRequired) {
705
            this.session.startOperationProfile(SessionProfiler.CACHE);
719
            this.session.startOperationProfile(SessionProfiler.Caching);
706
            acquireReadLock();
720
            acquireReadLock();
707
            try {
721
            try {
708
                cacheKey = map.getCacheKey(key);
722
                cacheKey = map.getCacheKey(key);
Lines 724-735 Link Here
724
        }
738
        }
725
739
726
        if (this.isCacheAccessPreCheckRequired) {
740
        if (this.isCacheAccessPreCheckRequired) {
727
            this.session.endOperationProfile(SessionProfiler.CACHE);
741
            this.session.endOperationProfile(SessionProfiler.Caching);
728
            if (domainObject == null) {
729
                this.session.incrementProfile(SessionProfiler.CacheMisses);
730
            } else {
731
                this.session.incrementProfile(SessionProfiler.CacheHits);
732
            }
733
        }
742
        }
734
743
735
        return domainObject;
744
        return domainObject;
Lines 737-743 Link Here
737
746
738
    public Object getFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) {
747
    public Object getFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) {
739
        UnitOfWorkImpl unitOfWork = (conforming) ? (UnitOfWorkImpl)this.session : null;
748
        UnitOfWorkImpl unitOfWork = (conforming) ? (UnitOfWorkImpl)this.session : null;
740
        this.session.startOperationProfile(SessionProfiler.CACHE);
749
        this.session.startOperationProfile(SessionProfiler.Caching);
741
        try {
750
        try {
742
            if (selectionCriteria != null) {
751
            if (selectionCriteria != null) {
743
                // PERF: Avoid clone of expression.            
752
                // PERF: Avoid clone of expression.            
Lines 768-774 Link Here
768
                    if (selectionCriteria == null) {
777
                    if (selectionCriteria == null) {
769
                        // bug 2782991: if first found was deleted nothing returned. 
778
                        // bug 2782991: if first found was deleted nothing returned. 
770
                        if (!(conforming && unitOfWork.isObjectDeleted(object))) {
779
                        if (!(conforming && unitOfWork.isObjectDeleted(object))) {
771
                            this.session.incrementProfile(SessionProfiler.CacheHits);
772
                            return object;
780
                            return object;
773
                        }
781
                        }
774
                    }
782
                    }
Lines 778-784 Link Here
778
                        if (selectionCriteria.doesConform(object, this.session, (AbstractRecord)translationRow, valueHolderPolicy)) {
786
                        if (selectionCriteria.doesConform(object, this.session, (AbstractRecord)translationRow, valueHolderPolicy)) {
779
                            // bug 2782991: if first found was deleted nothing returned. 
787
                            // bug 2782991: if first found was deleted nothing returned. 
780
                            if (!(conforming && unitOfWork.isObjectDeleted(object))) {
788
                            if (!(conforming && unitOfWork.isObjectDeleted(object))) {
781
                                this.session.incrementProfile(SessionProfiler.CacheHits);
782
                                return object;
789
                                return object;
783
                            }
790
                            }
784
                        }
791
                        }
Lines 787-793 Link Here
787
                            if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED) {
794
                            if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED) {
788
                                // bug 2782991: if first found was deleted nothing returned. 
795
                                // bug 2782991: if first found was deleted nothing returned. 
789
                                if (!(conforming && unitOfWork.isObjectDeleted(object))) {
796
                                if (!(conforming && unitOfWork.isObjectDeleted(object))) {
790
                                    this.session.incrementProfile(SessionProfiler.CacheHits);
791
                                    return object;
797
                                    return object;
792
                                }
798
                                }
793
                            } else if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_NOT_CONFORMED) {
799
                            } else if (valueHolderPolicy == InMemoryQueryIndirectionPolicy.SHOULD_IGNORE_EXCEPTION_RETURN_NOT_CONFORMED) {
Lines 802-808 Link Here
802
                }
808
                }
803
            }
809
            }
804
        } finally {
810
        } finally {
805
            this.session.endOperationProfile(SessionProfiler.CACHE);
811
            this.session.endOperationProfile(SessionProfiler.Caching);
806
        }
812
        }
807
        return null;
813
        return null;
808
    }
814
    }
Lines 813-819 Link Here
813
     */
819
     */
814
    public Object getFromIdentityMapWithDeferredLock(Object key, Class theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) {
820
    public Object getFromIdentityMapWithDeferredLock(Object key, Class theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) {
815
        if (key == null) {
821
        if (key == null) {
816
            this.session.incrementProfile(SessionProfiler.CacheMisses);
817
            return null;
822
            return null;
818
        }
823
        }
819
824
Lines 824-830 Link Here
824
        CacheKey cacheKey;
829
        CacheKey cacheKey;
825
        Object domainObject = null;
830
        Object domainObject = null;
826
        if (this.isCacheAccessPreCheckRequired) {
831
        if (this.isCacheAccessPreCheckRequired) {
827
            this.session.startOperationProfile(SessionProfiler.CACHE);
832
            this.session.startOperationProfile(SessionProfiler.Caching);
828
            acquireReadLock();
833
            acquireReadLock();
829
            try {
834
            try {
830
                cacheKey = map.getCacheKey(key);
835
                cacheKey = map.getCacheKey(key);
Lines 846-857 Link Here
846
851
847
852
848
        if (this.isCacheAccessPreCheckRequired) {
853
        if (this.isCacheAccessPreCheckRequired) {
849
            this.session.endOperationProfile(SessionProfiler.CACHE);
854
            this.session.endOperationProfile(SessionProfiler.Caching);
850
            if (domainObject == null) {
851
                this.session.incrementProfile(SessionProfiler.CacheMisses);
852
            } else {
853
                this.session.incrementProfile(SessionProfiler.CacheHits);
854
            }
855
        }
855
        }
856
856
857
        return domainObject;
857
        return domainObject;
Lines 968-981 Link Here
968
        IdentityMap map = getIdentityMap(descriptor, false);
968
        IdentityMap map = getIdentityMap(descriptor, false);
969
        Object wrapper;
969
        Object wrapper;
970
        if (this.isCacheAccessPreCheckRequired) {
970
        if (this.isCacheAccessPreCheckRequired) {
971
            this.session.startOperationProfile(SessionProfiler.CACHE);
971
            this.session.startOperationProfile(SessionProfiler.Caching);
972
            acquireReadLock();
972
            acquireReadLock();
973
            try {
973
            try {
974
                wrapper = map.getWrapper(primaryKey);
974
                wrapper = map.getWrapper(primaryKey);
975
            } finally {
975
            } finally {
976
                releaseReadLock();
976
                releaseReadLock();
977
            }
977
            }
978
            this.session.endOperationProfile(SessionProfiler.CACHE);
978
            this.session.endOperationProfile(SessionProfiler.Caching);
979
        } else {
979
        } else {
980
            wrapper = map.getWrapper(primaryKey);
980
            wrapper = map.getWrapper(primaryKey);
981
        }
981
        }
Lines 1006-1019 Link Here
1006
        IdentityMap map = getIdentityMap(descriptor, false);
1006
        IdentityMap map = getIdentityMap(descriptor, false);
1007
        Object value;
1007
        Object value;
1008
        if (this.isCacheAccessPreCheckRequired) {
1008
        if (this.isCacheAccessPreCheckRequired) {
1009
            this.session.startOperationProfile(SessionProfiler.CACHE);
1009
            this.session.startOperationProfile(SessionProfiler.Caching);
1010
            acquireReadLock();
1010
            acquireReadLock();
1011
            try {
1011
            try {
1012
                value = map.getWriteLockValue(primaryKey);
1012
                value = map.getWriteLockValue(primaryKey);
1013
            } finally {
1013
            } finally {
1014
                releaseReadLock();
1014
                releaseReadLock();
1015
            }
1015
            }
1016
            this.session.endOperationProfile(SessionProfiler.CACHE);
1016
            this.session.endOperationProfile(SessionProfiler.Caching);
1017
        } else {
1017
        } else {
1018
            value = map.getWriteLockValue(primaryKey);
1018
            value = map.getWriteLockValue(primaryKey);
1019
        }
1019
        }
Lines 1219-1225 Link Here
1219
        CacheKey cacheKey;
1219
        CacheKey cacheKey;
1220
1220
1221
        if (this.isCacheAccessPreCheckRequired) {
1221
        if (this.isCacheAccessPreCheckRequired) {
1222
            this.session.startOperationProfile(SessionProfiler.CACHE);
1222
            this.session.startOperationProfile(SessionProfiler.Caching);
1223
            // This is atomic so considered a read lock.
1223
            // This is atomic so considered a read lock.
1224
            acquireReadLock();
1224
            acquireReadLock();
1225
            try {
1225
            try {
Lines 1227-1233 Link Here
1227
            } finally {
1227
            } finally {
1228
                releaseReadLock();
1228
                releaseReadLock();
1229
            }
1229
            }
1230
            this.session.endOperationProfile(SessionProfiler.CACHE);
1230
            this.session.endOperationProfile(SessionProfiler.Caching);
1231
        } else {
1231
        } else {
1232
            cacheKey = map.put(keys, implementation, writeLockValue, readTime);
1232
            cacheKey = map.put(keys, implementation, writeLockValue, readTime);
1233
        }
1233
        }
Lines 1311-1317 Link Here
1311
        Object value;
1311
        Object value;
1312
1312
1313
        if (this.isCacheAccessPreCheckRequired) {
1313
        if (this.isCacheAccessPreCheckRequired) {
1314
            this.session.startOperationProfile(SessionProfiler.CACHE);
1314
            this.session.startOperationProfile(SessionProfiler.Caching);
1315
            // This is atomic so considered a read lock.
1315
            // This is atomic so considered a read lock.
1316
            acquireReadLock();
1316
            acquireReadLock();
1317
            try {
1317
            try {
Lines 1319-1325 Link Here
1319
            } finally {
1319
            } finally {
1320
                releaseReadLock();
1320
                releaseReadLock();
1321
            }
1321
            }
1322
            this.session.endOperationProfile(SessionProfiler.CACHE);
1322
            this.session.endOperationProfile(SessionProfiler.Caching);
1323
        } else {
1323
        } else {
1324
            value = map.remove(key, objectToRemove);
1324
            value = map.remove(key, objectToRemove);
1325
        }
1325
        }
Lines 1353-1359 Link Here
1353
        IdentityMap map = getIdentityMap(descriptor, false);
1353
        IdentityMap map = getIdentityMap(descriptor, false);
1354
1354
1355
        if (this.isCacheAccessPreCheckRequired) {
1355
        if (this.isCacheAccessPreCheckRequired) {
1356
            this.session.startOperationProfile(SessionProfiler.CACHE);
1356
            this.session.startOperationProfile(SessionProfiler.Caching);
1357
            // This is atomic so considered a read lock.
1357
            // This is atomic so considered a read lock.
1358
            acquireReadLock();
1358
            acquireReadLock();
1359
            try {
1359
            try {
Lines 1361-1367 Link Here
1361
            } finally {
1361
            } finally {
1362
                releaseReadLock();
1362
                releaseReadLock();
1363
            }
1363
            }
1364
            this.session.endOperationProfile(SessionProfiler.CACHE);
1364
            this.session.endOperationProfile(SessionProfiler.Caching);
1365
        } else {
1365
        } else {
1366
            map.setWrapper(primaryKey, wrapper);
1366
            map.setWrapper(primaryKey, wrapper);
1367
        }
1367
        }
Lines 1378-1384 Link Here
1378
        IdentityMap map = getIdentityMap(descriptor, false);
1378
        IdentityMap map = getIdentityMap(descriptor, false);
1379
1379
1380
        if (this.isCacheAccessPreCheckRequired) {
1380
        if (this.isCacheAccessPreCheckRequired) {
1381
            this.session.startOperationProfile(SessionProfiler.CACHE);
1381
            this.session.startOperationProfile(SessionProfiler.Caching);
1382
            // This is atomic so considered a read lock.
1382
            // This is atomic so considered a read lock.
1383
            acquireReadLock();
1383
            acquireReadLock();
1384
            try {
1384
            try {
Lines 1386-1392 Link Here
1386
            } finally {
1386
            } finally {
1387
                releaseReadLock();
1387
                releaseReadLock();
1388
            }
1388
            }
1389
            this.session.endOperationProfile(SessionProfiler.CACHE);
1389
            this.session.endOperationProfile(SessionProfiler.Caching);
1390
        } else {
1390
        } else {
1391
            map.setWriteLockValue(primaryKey, writeLockValue);
1391
            map.setWriteLockValue(primaryKey, writeLockValue);
1392
        }
1392
        }
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLObjectBuilder.java (-2 / +2 lines)
Lines 236-242 Link Here
236
        if (!(isXmlDescriptor() || getDescriptor().isDescriptorTypeAggregate())) {
236
        if (!(isXmlDescriptor() || getDescriptor().isDescriptorTypeAggregate())) {
237
            return super.buildObject(query, databaseRow, joinManager);
237
            return super.buildObject(query, databaseRow, joinManager);
238
        }
238
        }
239
        query.getSession().startOperationProfile(SessionProfiler.OBJECT_BUILDING, query, SessionProfiler.ALL);
239
        query.getSession().startOperationProfile(SessionProfiler.ObjectBuilding, query, SessionProfiler.ALL);
240
        ClassDescriptor concreteDescriptor = getDescriptor();
240
        ClassDescriptor concreteDescriptor = getDescriptor();
241
        Object domainObject = null;
241
        Object domainObject = null;
242
242
Lines 303-309 Link Here
303
            //EIS XML Cases won't have a doc pres policy set
303
            //EIS XML Cases won't have a doc pres policy set
304
            ((DOMRecord)row).getDocPresPolicy().addObjectToCache(domainObject, ((DOMRecord)row).getDOM());
304
            ((DOMRecord)row).getDocPresPolicy().addObjectToCache(domainObject, ((DOMRecord)row).getDOM());
305
        }
305
        }
306
        query.getSession().endOperationProfile(SessionProfiler.OBJECT_BUILDING, query, SessionProfiler.ALL);
306
        query.getSession().endOperationProfile(SessionProfiler.ObjectBuilding, query, SessionProfiler.ALL);
307
        if ((unmarshaller != null) && (unmarshaller.getUnmarshalListener() != null)) {
307
        if ((unmarshaller != null) && (unmarshaller.getUnmarshalListener() != null)) {
308
            unmarshaller.getUnmarshalListener().afterUnmarshal(domainObject, parent);
308
            unmarshaller.getUnmarshalListener().afterUnmarshal(domainObject, parent);
309
        }
309
        }
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/queries/StatementQueryMechanism.java (-22 / +24 lines)
Lines 365-401 Link Here
365
     */
365
     */
366
    protected void setCallFromStatement() {
366
    protected void setCallFromStatement() {
367
        // Profile SQL generation.
367
        // Profile SQL generation.
368
        getSession().startOperationProfile(SessionProfiler.SQL_GENERATION, getQuery(), SessionProfiler.ALL);
368
        getSession().startOperationProfile(SessionProfiler.SqlGeneration, getQuery(), SessionProfiler.ALL);
369
        if (hasMultipleStatements()) {
369
        try {
370
            for (Enumeration statementEnum = getSQLStatements().elements(); statementEnum.hasMoreElements();) {
370
            if (hasMultipleStatements()) {
371
                for (Enumeration statementEnum = getSQLStatements().elements(); statementEnum.hasMoreElements();) {
372
                    DatabaseCall call = null;
373
                    if (getDescriptor() != null) {
374
                        call = getDescriptor().buildCallFromStatement((SQLStatement)statementEnum.nextElement(), getSession());
375
                    } else {
376
                        call = ((SQLStatement)statementEnum.nextElement()).buildCall(getSession());
377
                    }
378
    
379
                    // In case of update call may be null if no update required.
380
                    if (call != null) {
381
                        addCall(call);
382
                    }
383
                }
384
            } else {
371
                DatabaseCall call = null;
385
                DatabaseCall call = null;
372
                if (getDescriptor() != null) {
386
                if (getDescriptor() != null) {
373
                    call = getDescriptor().buildCallFromStatement((SQLStatement)statementEnum.nextElement(), getSession());
387
                    call = getDescriptor().buildCallFromStatement(getSQLStatement(), getSession());
374
                } else {
388
                } else {
375
                    call = ((SQLStatement)statementEnum.nextElement()).buildCall(getSession());
389
                    call = getSQLStatement().buildCall(getSession());
376
                }
390
                }
377
391
    
378
                // In case of update call may be null if no update required.
392
                // In case of update call may be null if no update required.
379
                if (call != null) {
393
                if (call != null) {
380
                    addCall(call);
394
                    setCall(call);
381
                }
395
                }
382
            }
396
            }
383
        } else {
397
        } finally {
384
            DatabaseCall call = null;
398
            // Profile SQL generation.
385
            if (getDescriptor() != null) {
399
            getSession().endOperationProfile(SessionProfiler.SqlGeneration, getQuery(), SessionProfiler.ALL);
386
                call = getDescriptor().buildCallFromStatement(getSQLStatement(), getSession());
387
            } else {
388
                call = getSQLStatement().buildCall(getSession());
389
            }
390
391
            // In case of update call may be null if no update required.
392
            if (call != null) {
393
                setCall(call);
394
            }
395
        }
400
        }
396
397
        // Profile SQL generation.
398
        getSession().endOperationProfile(SessionProfiler.SQL_GENERATION, getQuery(), SessionProfiler.ALL);
399
    }
401
    }
400
402
401
    /**
403
    /**
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/AbstractSession.java (+10 lines)
Lines 967-972 Link Here
967
967
968
    /**
968
    /**
969
     * INTERNAL:
969
     * INTERNAL:
970
     * Updates the count of SessionProfiler event
971
     */
972
    public void incrementProfile(String operationName, DatabaseQuery query) {
973
        if (this.isInProfile) {
974
            getProfiler().occurred(operationName, query);
975
        }
976
    }
977
978
    /**
979
     * INTERNAL:
970
     * Overridden by subclasses that do more than just execute the call.
980
     * Overridden by subclasses that do more than just execute the call.
971
     * Executes the call directly on this session and does not check which
981
     * Executes the call directly on this session and does not check which
972
     * session it should have executed on.
982
     * session it should have executed on.
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/DatabaseSessionImpl.java (+1 lines)
Lines 642-647 Link Here
642
            getProfiler().initialize();
642
            getProfiler().initialize();
643
        }
643
        }
644
        updateProfile(SessionProfiler.LoginTime, new Date(System.currentTimeMillis()));
644
        updateProfile(SessionProfiler.LoginTime, new Date(System.currentTimeMillis()));
645
        updateProfile(SessionProfiler.SessionName, getName());
645
646
646
        // Login and initialize
647
        // Login and initialize
647
        if (this.eventManager != null) {
648
        if (this.eventManager != null) {
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/MergeManager.java (-9 / +7 lines)
Lines 327-340 Link Here
327
     */
327
     */
328
    public void mergeChangesFromChangeSet(UnitOfWorkChangeSet uowChangeSet) {
328
    public void mergeChangesFromChangeSet(UnitOfWorkChangeSet uowChangeSet) {
329
        this.session.startOperationProfile(SessionProfiler.DistributedMerge);
329
        this.session.startOperationProfile(SessionProfiler.DistributedMerge);
330
        // Ensure concurrency if cache isolation requires.
331
        this.session.getIdentityMapAccessorInstance().acquireWriteLock();
332
        this.session.log(SessionLog.FINER, SessionLog.PROPAGATION, "received_updates_from_remote_server");
333
        if (this.session.hasEventManager()) {
334
            this.session.getEventManager().preDistributedMergeUnitOfWorkChangeSet(uowChangeSet);
335
        }
336
337
        try {
330
        try {
331
            // Ensure concurrency if cache isolation requires.
332
            this.session.getIdentityMapAccessorInstance().acquireWriteLock();
333
            this.session.log(SessionLog.FINER, SessionLog.PROPAGATION, "received_updates_from_remote_server");
334
            if (this.session.hasEventManager()) {
335
                this.session.getEventManager().preDistributedMergeUnitOfWorkChangeSet(uowChangeSet);
336
            }
338
            // Iterate over each clone and let the object build merge to clones into the originals.
337
            // Iterate over each clone and let the object build merge to clones into the originals.
339
            this.session.getIdentityMapAccessorInstance().getWriteLockManager().acquireRequiredLocks(this, uowChangeSet);
338
            this.session.getIdentityMapAccessorInstance().getWriteLockManager().acquireRequiredLocks(this, uowChangeSet);
340
            Iterator objectChangeEnum = uowChangeSet.getAllChangeSets().keySet().iterator();
339
            Iterator objectChangeEnum = uowChangeSet.getAllChangeSets().keySet().iterator();
Lines 358-364 Link Here
358
                while (deletedObjects.hasNext()) {
357
                while (deletedObjects.hasNext()) {
359
                    ObjectChangeSet changeSet = (ObjectChangeSet)deletedObjects.next();
358
                    ObjectChangeSet changeSet = (ObjectChangeSet)deletedObjects.next();
360
                    changeSet.removeFromIdentityMap(this.session);
359
                    changeSet.removeFromIdentityMap(this.session);
361
                    this.session.incrementProfile(SessionProfiler.DeletedObject);
362
                }
360
                }
363
            }
361
            }
364
        } catch (RuntimeException exception) {
362
        } catch (RuntimeException exception) {
Lines 366-375 Link Here
366
        } finally {
364
        } finally {
367
            this.session.getIdentityMapAccessorInstance().getWriteLockManager().releaseAllAcquiredLocks(this);
365
            this.session.getIdentityMapAccessorInstance().getWriteLockManager().releaseAllAcquiredLocks(this);
368
            this.session.getIdentityMapAccessorInstance().releaseWriteLock();
366
            this.session.getIdentityMapAccessorInstance().releaseWriteLock();
367
            this.session.endOperationProfile(SessionProfiler.DistributedMerge);
369
            if (this.session.hasEventManager()) {
368
            if (this.session.hasEventManager()) {
370
                this.session.getEventManager().postDistributedMergeUnitOfWorkChangeSet(uowChangeSet);
369
                this.session.getEventManager().postDistributedMergeUnitOfWorkChangeSet(uowChangeSet);
371
            }
370
            }
372
            this.session.endOperationProfile(SessionProfiler.DistributedMerge);
373
        }
371
        }
374
    }
372
    }
375
373
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/UnitOfWorkImpl.java (-43 / +39 lines)
Lines 1495-1500 Link Here
1495
    protected void commitToDatabaseWithChangeSet(boolean commitTransaction) throws DatabaseException, OptimisticLockException {
1495
    protected void commitToDatabaseWithChangeSet(boolean commitTransaction) throws DatabaseException, OptimisticLockException {
1496
        
1496
        
1497
        try {
1497
        try {
1498
            incrementProfile(SessionProfiler.UowCommits);
1498
            startOperationProfile(SessionProfiler.UowCommit);
1499
            startOperationProfile(SessionProfiler.UowCommit);
1499
            // PERF: If this is an empty unit of work, do nothing (but still may need to commit SQL changes).
1500
            // PERF: If this is an empty unit of work, do nothing (but still may need to commit SQL changes).
1500
            boolean hasChanges = (this.unitOfWorkChangeSet != null) || hasCloneMapping() || hasDeletedObjects() || hasModifyAllQueries() || hasDeferredModifyAllQueries();
1501
            boolean hasChanges = (this.unitOfWorkChangeSet != null) || hasCloneMapping() || hasDeletedObjects() || hasModifyAllQueries() || hasDeferredModifyAllQueries();
Lines 3562-3615 Link Here
3562
     * support.
3563
     * support.
3563
     */
3564
     */
3564
    public void performRemove(Object toBeDeleted, Map visitedObjects) {
3565
    public void performRemove(Object toBeDeleted, Map visitedObjects) {
3565
        try {
3566
        if (toBeDeleted == null) {
3566
            if (toBeDeleted == null) {
3567
            return;
3567
                return;
3568
        }
3568
            }
3569
        ClassDescriptor descriptor = getDescriptor(toBeDeleted);
3569
            ClassDescriptor descriptor = getDescriptor(toBeDeleted);
3570
        if ((descriptor == null) || descriptor.isDescriptorTypeAggregate()) {
3570
            if ((descriptor == null) || descriptor.isDescriptorTypeAggregate()) {
3571
            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { toBeDeleted }));
3571
                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { toBeDeleted }));
3572
        }
3572
            }
3573
        logDebugMessage(toBeDeleted, "deleting_object");
3573
            logDebugMessage(toBeDeleted, "deleting_object");
3574
3574
3575
            startOperationProfile(SessionProfiler.DeletedObject);
3575
        //bug 4568370+4599010; fix EntityManager.remove() to handle new objects
3576
            //bug 4568370+4599010; fix EntityManager.remove() to handle new objects
3576
        if (getDeletedObjects().containsKey(toBeDeleted)){
3577
            if (getDeletedObjects().containsKey(toBeDeleted)){
3577
          return;
3578
              return;
3578
        }
3579
            }
3579
        visitedObjects.put(toBeDeleted,toBeDeleted);
3580
            visitedObjects.put(toBeDeleted,toBeDeleted);
3580
        Object registeredObject = checkIfAlreadyRegistered(toBeDeleted, descriptor);
3581
            Object registeredObject = checkIfAlreadyRegistered(toBeDeleted, descriptor);
3581
        if (registeredObject == null) {
3582
            if (registeredObject == null) {
3582
            Object primaryKey = descriptor.getObjectBuilder().extractPrimaryKeyFromObject(toBeDeleted, this);
3583
                Object primaryKey = descriptor.getObjectBuilder().extractPrimaryKeyFromObject(toBeDeleted, this);
3583
            DoesExistQuery existQuery = descriptor.getQueryManager().getDoesExistQuery();
3584
                DoesExistQuery existQuery = descriptor.getQueryManager().getDoesExistQuery();
3584
            existQuery = (DoesExistQuery)existQuery.clone();
3585
                existQuery = (DoesExistQuery)existQuery.clone();
3585
            existQuery.setObject(toBeDeleted);
3586
                existQuery.setObject(toBeDeleted);
3586
            existQuery.setPrimaryKey(primaryKey);
3587
                existQuery.setPrimaryKey(primaryKey);
3587
            existQuery.setDescriptor(descriptor);
3588
                existQuery.setDescriptor(descriptor);
3588
            existQuery.setIsExecutionClone(true);
3589
                existQuery.setIsExecutionClone(true);
3590
3589
3591
                existQuery.setCheckCacheFirst(true);
3590
            existQuery.setCheckCacheFirst(true);
3592
                if (((Boolean)executeQuery(existQuery)).booleanValue()){
3591
            if (((Boolean)executeQuery(existQuery)).booleanValue()){
3593
                    throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cannot_remove_detatched_entity", new Object[]{toBeDeleted}));
3592
                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cannot_remove_detatched_entity", new Object[]{toBeDeleted}));
3594
                }//else, it is a new or previously deleted object that should be ignored (and delete should cascade)
3593
            }//else, it is a new or previously deleted object that should be ignored (and delete should cascade)
3594
        } else {
3595
            //fire events only if this is a managed object
3596
            if (descriptor.getEventManager().hasAnyEventListeners()) {
3597
                org.eclipse.persistence.descriptors.DescriptorEvent event = new org.eclipse.persistence.descriptors.DescriptorEvent(toBeDeleted);
3598
                event.setEventCode(DescriptorEventManager.PreRemoveEvent);
3599
                event.setSession(this);
3600
                descriptor.getEventManager().executeEvent(event);
3601
            }
3602
            if (hasNewObjects() && getNewObjectsCloneToOriginal().containsKey(registeredObject)){
3603
                unregisterObject(registeredObject, DescriptorIterator.NoCascading);
3595
            } else {
3604
            } else {
3596
                //fire events only if this is a managed object
3605
                getDeletedObjects().put(toBeDeleted, toBeDeleted);
3597
                if (descriptor.getEventManager().hasAnyEventListeners()) {
3598
                    org.eclipse.persistence.descriptors.DescriptorEvent event = new org.eclipse.persistence.descriptors.DescriptorEvent(toBeDeleted);
3599
                    event.setEventCode(DescriptorEventManager.PreRemoveEvent);
3600
                    event.setSession(this);
3601
                    descriptor.getEventManager().executeEvent(event);
3602
                }
3603
                if (hasNewObjects() && getNewObjectsCloneToOriginal().containsKey(registeredObject)){
3604
                    unregisterObject(registeredObject, DescriptorIterator.NoCascading);
3605
                } else {
3606
                    getDeletedObjects().put(toBeDeleted, toBeDeleted);
3607
                }
3608
            }
3606
            }
3609
            descriptor.getObjectBuilder().cascadePerformRemove(toBeDeleted, this, visitedObjects);
3610
        } finally {
3611
            endOperationProfile(SessionProfiler.DeletedObject);
3612
        }
3607
        }
3608
        descriptor.getObjectBuilder().cascadePerformRemove(toBeDeleted, this, visitedObjects);
3613
    }
3609
    }
3614
3610
3615
    /**
3611
    /**
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/mappings/ManyToManyMapping.java (+1 lines)
Lines 542-547 Link Here
542
        if (!getDeleteAllQuery().hasSessionName()) {
542
        if (!getDeleteAllQuery().hasSessionName()) {
543
            getDeleteAllQuery().setSessionName(session.getName());
543
            getDeleteAllQuery().setSessionName(session.getName());
544
        }
544
        }
545
        getDeleteAllQuery().setName(getAttributeName());
545
546
546
        if (hasCustomDeleteAllQuery()) {
547
        if (hasCustomDeleteAllQuery()) {
547
            return;
548
            return;
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/mappings/OneToManyMapping.java (+1 lines)
Lines 566-571 Link Here
566
     */
566
     */
567
    protected void initializeDeleteAllQuery() {
567
    protected void initializeDeleteAllQuery() {
568
        ((DeleteAllQuery)getDeleteAllQuery()).setReferenceClass(getReferenceClass());
568
        ((DeleteAllQuery)getDeleteAllQuery()).setReferenceClass(getReferenceClass());
569
        getDeleteAllQuery().setName(getAttributeName());
569
        if (!hasCustomDeleteAllQuery()) {
570
        if (!hasCustomDeleteAllQuery()) {
570
            // the selection criteria are re-used by the delete all query
571
            // the selection criteria are re-used by the delete all query
571
            if (getSelectionCriteria() == null) {
572
            if (getSelectionCriteria() == null) {
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/mappings/RelationTableMechanism.java (+2 lines)
Lines 542-547 Link Here
542
        if (!getDeleteQuery().hasSessionName()) {
542
        if (!getDeleteQuery().hasSessionName()) {
543
            getDeleteQuery().setSessionName(session.getName());
543
            getDeleteQuery().setSessionName(session.getName());
544
        }
544
        }
545
        getInsertQuery().setName(mapping.getAttributeName());
545
        if (hasCustomDeleteQuery()) {
546
        if (hasCustomDeleteQuery()) {
546
            return;
547
            return;
547
        }
548
        }
Lines 611-616 Link Here
611
        if (!getInsertQuery().hasSessionName()) {
612
        if (!getInsertQuery().hasSessionName()) {
612
            getInsertQuery().setSessionName(session.getName());
613
            getInsertQuery().setSessionName(session.getName());
613
        }
614
        }
615
        getInsertQuery().setName(mapping.getAttributeName());
614
        if (hasCustomInsertQuery()) {
616
        if (hasCustomInsertQuery()) {
615
            return;
617
            return;
616
        }
618
        }
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/SQLServerPlatform.java (-2 / +2 lines)
Lines 362-372 Link Here
362
        } else {
362
        } else {
363
            // start the process of processing the result set and the output params.  this is specific to Sybase JConnect 5.5
363
            // start the process of processing the result set and the output params.  this is specific to Sybase JConnect 5.5
364
            // as we must process the result set before the output params.
364
            // as we must process the result set before the output params.
365
            session.startOperationProfile(SessionProfiler.STATEMENT_EXECUTE, dbCall.getQuery(), SessionProfiler.ALL);
365
            session.startOperationProfile(SessionProfiler.StatementExecute, dbCall.getQuery(), SessionProfiler.ALL);
366
            try {
366
            try {
367
                resultSet = statement.executeQuery();
367
                resultSet = statement.executeQuery();
368
            } finally {
368
            } finally {
369
                session.endOperationProfile(SessionProfiler.STATEMENT_EXECUTE, dbCall.getQuery(), SessionProfiler.ALL);
369
                session.endOperationProfile(SessionProfiler.StatementExecute, dbCall.getQuery(), SessionProfiler.ALL);
370
            }
370
            }
371
            dbCall.matchFieldOrder(resultSet, accessor, session);
371
            dbCall.matchFieldOrder(resultSet, accessor, session);
372
372
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/SybasePlatform.java (-2 / +2 lines)
Lines 261-271 Link Here
261
        } else {
261
        } else {
262
            // start the process of processing the result set and the output params.  this is specific to Sybase JConnect 5.5
262
            // start the process of processing the result set and the output params.  this is specific to Sybase JConnect 5.5
263
            // as we must process the result set before the output params.
263
            // as we must process the result set before the output params.
264
            session.startOperationProfile(SessionProfiler.STATEMENT_EXECUTE, dbCall.getQuery(), SessionProfiler.ALL);
264
            session.startOperationProfile(SessionProfiler.StatementExecute, dbCall.getQuery(), SessionProfiler.ALL);
265
            try {
265
            try {
266
                resultSet = statement.executeQuery();
266
                resultSet = statement.executeQuery();
267
            } finally {
267
            } finally {
268
                session.endOperationProfile(SessionProfiler.STATEMENT_EXECUTE, dbCall.getQuery(), SessionProfiler.ALL);
268
                session.endOperationProfile(SessionProfiler.StatementExecute, dbCall.getQuery(), SessionProfiler.ALL);
269
            }
269
            }
270
            dbCall.matchFieldOrder(resultSet, accessor, session);
270
            dbCall.matchFieldOrder(resultSet, accessor, session);
271
271
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/DatabaseQuery.java (-65 / +33 lines)
Lines 263-270 Link Here
263
263
264
    /** Allow connection unwrapping to be configured. */
264
    /** Allow connection unwrapping to be configured. */
265
    protected boolean isNativeConnectionRequired;
265
    protected boolean isNativeConnectionRequired;
266
266
    
267
    /**
267
    /**
268
     * Return the name to use for the query in performance monitoring.
269
     */
270
    protected String monitorName;
271
    
272
    /**
268
     * PUBLIC: Initialize the state of the query
273
     * PUBLIC: Initialize the state of the query
269
     */
274
     */
270
    public DatabaseQuery() {
275
    public DatabaseQuery() {
Lines 284-289 Link Here
284
    }
289
    }
285
290
286
    /**
291
    /**
292
     * INTERNAL:
293
     * Return the name to use for the query in performance monitoring.
294
     */
295
    public String getMonitorName() {
296
        if (monitorName == null) {
297
            resetMonitorName();
298
        }
299
        return monitorName;
300
    }
301
302
    /**
303
     * INTERNAL:
304
     * Return the name to use for the query in performance monitoring.
305
     */
306
    public void resetMonitorName() {
307
        if (getReferenceClassName() == null) {
308
            this.monitorName = getClass().getSimpleName() + ":" + getName();
309
        } else {
310
            this.monitorName = getClass().getSimpleName() + ":" + getReferenceClassName() + ":" + getName();                
311
        }
312
    }
313
    
314
    /**
287
     * PUBLIC: Add the argument named argumentName. This will cause the
315
     * PUBLIC: Add the argument named argumentName. This will cause the
288
     * translation of references of argumentName in the receiver's expression,
316
     * translation of references of argumentName in the receiver's expression,
289
     * with the value of the argument as supplied to the query in order from
317
     * with the value of the argument as supplied to the query in order from
Lines 481-491 Link Here
481
            if (!this.isPrepared) {// Avoid the monitor is already prepare, must
509
            if (!this.isPrepared) {// Avoid the monitor is already prepare, must
482
                // check again for concurrency.
510
                // check again for concurrency.
483
                // Profile the query preparation time.
511
                // Profile the query preparation time.
484
                session.startOperationProfile(SessionProfiler.QUERY_PREPARE, this, SessionProfiler.ALL);
512
                session.startOperationProfile(SessionProfiler.QueryPreparation, this, SessionProfiler.ALL);
485
                // If this query will use the custom query, do not prepare.
513
                // If this query will use the custom query, do not prepare.
486
                if ((!force) && shouldPrepare() && (checkForCustomQuery(session, translationRow) != null)) {
514
                if ((!force) && shouldPrepare() && (checkForCustomQuery(session, translationRow) != null)) {
487
                    // Profile the query preparation time.
515
                    // Profile the query preparation time.
488
                    session.endOperationProfile(SessionProfiler.QUERY_PREPARE, this, SessionProfiler.ALL);
516
                    session.endOperationProfile(SessionProfiler.QueryPreparation, this, SessionProfiler.ALL);
489
                    return;
517
                    return;
490
                }
518
                }
491
                // Prepared queries cannot be custom as then they would never have
519
                // Prepared queries cannot be custom as then they would never have
Lines 513-519 Link Here
513
                    }
541
                    }
514
                }
542
                }
515
                // Profile the query preparation time.
543
                // Profile the query preparation time.
516
                session.endOperationProfile(SessionProfiler.QUERY_PREPARE, this, SessionProfiler.ALL);
544
                session.endOperationProfile(SessionProfiler.QueryPreparation, this, SessionProfiler.ALL);
517
            }
545
            }
518
        } catch (EclipseLinkException knownFailure) {
546
        } catch (EclipseLinkException knownFailure) {
519
            throw knownFailure;
547
            throw knownFailure;
Lines 1518-1523 Link Here
1518
        this.argumentFields = buildArgumentFields();
1546
        this.argumentFields = buildArgumentFields();
1519
1547
1520
        getQueryMechanism().prepare();
1548
        getQueryMechanism().prepare();
1549
        resetMonitorName();
1521
    }
1550
    }
1522
1551
1523
    /**
1552
    /**
Lines 2244-2310 Link Here
2244
    }
2273
    }
2245
2274
2246
    /**
2275
    /**
2247
     * INTERNAL: TopLink_sessionName_domainClass. Cached in properties
2248
     */
2249
    public String getDomainClassNounName(String sessionName) {
2250
        if (getProperty("DMSDomainClassNounName") == null) {
2251
            StringBuffer buffer = new StringBuffer("EclipseLink");
2252
            if (sessionName != null) {
2253
                buffer.append(sessionName);
2254
            }
2255
            if (getReferenceClassName() != null) {
2256
                buffer.append("_");
2257
                buffer.append(getReferenceClassName());
2258
            }
2259
            setProperty("DMSDomainClassNounName", buffer.toString());
2260
        }
2261
        return (String) getProperty("DMSDomainClassNounName");
2262
    }
2263
2264
    /**
2265
     * INTERNAL: TopLink_sessionName_domainClass_queryClass_queryName (if
2266
     * exist). Cached in properties
2267
     */
2268
    public String getQueryNounName(String sessionName) {
2269
        if (getProperty("DMSQueryNounName") == null) {
2270
            StringBuffer buffer = new StringBuffer(getDomainClassNounName(sessionName));
2271
            buffer.append("_");
2272
            buffer.append(getClass().getSimpleName());
2273
            if (getName() != null) {
2274
                buffer.append("_");
2275
                buffer.append(getName());
2276
            }
2277
            setProperty("DMSQueryNounName", buffer.toString());
2278
        }
2279
        return (String) getProperty("DMSQueryNounName");
2280
    }
2281
2282
    /**
2283
     * INTERNAL: TopLink_sessionName_domainClass_queryClass_queryName (if
2284
     * exist)_operationName (if exist). Cached in properties
2285
     */
2286
    public String getSensorName(String operationName, String sessionName) {
2287
        if (operationName == null) {
2288
            return getQueryNounName(sessionName);
2289
        }
2290
2291
        Hashtable sensorNames = (Hashtable) getProperty("DMSSensorNames");
2292
        if (sensorNames == null) {
2293
            sensorNames = new Hashtable();
2294
            setProperty("DMSSensorNames", sensorNames);
2295
        }
2296
        Object sensorName = sensorNames.get(operationName);
2297
        if (sensorName == null) {
2298
            StringBuffer buffer = new StringBuffer(getQueryNounName(sessionName));
2299
            buffer.append("_");
2300
            buffer.append(operationName);
2301
            sensorName = buffer.toString();
2302
            sensorNames.put(operationName, sensorName);
2303
        }
2304
        return (String) sensorName;
2305
    }
2306
2307
    /**
2308
     * ADVANCED: Set if the descriptor requires usage of a native (unwrapped)
2276
     * ADVANCED: Set if the descriptor requires usage of a native (unwrapped)
2309
     * JDBC connection. This may be required for some Oracle JDBC support when a
2277
     * JDBC connection. This may be required for some Oracle JDBC support when a
2310
     * wrapping DataSource is used.
2278
     * wrapping DataSource is used.
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/ObjectLevelModifyQuery.java (-4 / +16 lines)
Lines 149-158 Link Here
149
     * Return the domain class associated with this query.
149
     * Return the domain class associated with this query.
150
     */
150
     */
151
    public Class getReferenceClass() {
151
    public Class getReferenceClass() {
152
        if (getObject() == null) {
152
        if (this.object == null) {
153
            if (this.descriptor != null) {
154
                return this.descriptor.getJavaClass();
155
            }
153
            return null;
156
            return null;
154
        }
157
        }
155
        return getObject().getClass();        
158
        return this.object.getClass();        
156
    }
159
    }
157
160
158
    /**
161
    /**
Lines 162-175 Link Here
162
     * is specified at runtime, this will not be an issue.
165
     * is specified at runtime, this will not be an issue.
163
     */
166
     */
164
    public String getReferenceClassName() {
167
    public String getReferenceClassName() {
165
        if (getReferenceClass() != null) {
168
        Class referenceClass = getReferenceClass();
166
            return getReferenceClass().getName();
169
        if (referenceClass != null) {
170
            return referenceClass.getName();
167
        } else {
171
        } else {
168
            return null;
172
            return null;
169
        }
173
        }
170
    }
174
    }
171
175
172
    /**
176
    /**
177
     * INTERNAL:
178
     * Return the name to use for the query in performance monitoring.
179
     */
180
    public void resetMonitorName() {
181
        this.monitorName = getClass().getSimpleName() + ":" + getReferenceClassName();
182
    }
183
184
    /**
173
     * PUBLIC:
185
     * PUBLIC:
174
     * Return if this is an object level modify query.
186
     * Return if this is an object level modify query.
175
     */
187
     */
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/ObjectLevelReadQuery.java (-3 / +3 lines)
Lines 416-422 Link Here
416
            cloneQuery.orderByExpressions = new ArrayList<Expression>(this.orderByExpressions);
416
            cloneQuery.orderByExpressions = new ArrayList<Expression>(this.orderByExpressions);
417
        }
417
        }
418
        if (this.fetchGroup != null) {
418
        if (this.fetchGroup != null) {
419
            cloneQuery.fetchGroup = (FetchGroup)this.fetchGroup.clone();
419
            cloneQuery.fetchGroup = this.fetchGroup.clone();
420
            // don't clone immutable entityFetchGroup
420
            // don't clone immutable entityFetchGroup
421
        }
421
        }
422
        return cloneQuery;
422
        return cloneQuery;
Lines 637-649 Link Here
637
        ClassDescriptor referenceDescriptor = mapping.getReferenceDescriptor();
637
        ClassDescriptor referenceDescriptor = mapping.getReferenceDescriptor();
638
638
639
        // Add the fields defined by the nested fetch group - if it exists.
639
        // Add the fields defined by the nested fetch group - if it exists.
640
        if(referenceDescriptor != null && referenceDescriptor.hasFetchGroupManager()) {
640
        if (referenceDescriptor != null && referenceDescriptor.hasFetchGroupManager()) {
641
            ObjectLevelReadQuery nestedQuery = getJoinedAttributeManager().getNestedJoinedMappingQuery(expression);
641
            ObjectLevelReadQuery nestedQuery = getJoinedAttributeManager().getNestedJoinedMappingQuery(expression);
642
            FetchGroup nestedFetchGroup = nestedQuery.getExecutionFetchGroup();
642
            FetchGroup nestedFetchGroup = nestedQuery.getExecutionFetchGroup();
643
            if(nestedFetchGroup != null) {
643
            if(nestedFetchGroup != null) {
644
                List<DatabaseField> nestedFields = nestedQuery.getFetchGroupSelectionFields(mapping);
644
                List<DatabaseField> nestedFields = nestedQuery.getFetchGroupSelectionFields(mapping);
645
                for(DatabaseField field : nestedFields) {
645
                for(DatabaseField field : nestedFields) {
646
                    fields.add(new FieldExpression((DatabaseField)field, expression));
646
                    fields.add(new FieldExpression(field, expression));
647
                }
647
                }
648
                return;
648
                return;
649
            }
649
            }
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/ReadAllQuery.java (-1 / +4 lines)
Lines 25-30 Link Here
25
import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
25
import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
26
import org.eclipse.persistence.exceptions.*;
26
import org.eclipse.persistence.exceptions.*;
27
import org.eclipse.persistence.expressions.*;
27
import org.eclipse.persistence.expressions.*;
28
import org.eclipse.persistence.sessions.SessionProfiler;
28
import org.eclipse.persistence.sessions.remote.*;
29
import org.eclipse.persistence.sessions.remote.*;
29
import org.eclipse.persistence.tools.profiler.QueryMonitor;
30
import org.eclipse.persistence.tools.profiler.QueryMonitor;
30
31
Lines 353-359 Link Here
353
                if (queryResults != null) {
354
                if (queryResults != null) {
354
                    if (QueryMonitor.shouldMonitor()) {
355
                    if (QueryMonitor.shouldMonitor()) {
355
                        QueryMonitor.incrementReadAllHits(this);
356
                        QueryMonitor.incrementReadAllHits(this);
356
                    }                    
357
                    }
358
                    session.incrementProfile(SessionProfiler.CacheHits, this);
357
                    // bug6138532 - check for "cached no results" (InvalidObject singleton) in query 
359
                    // bug6138532 - check for "cached no results" (InvalidObject singleton) in query 
358
                    // results, and return an empty container instance as configured
360
                    // results, and return an empty container instance as configured
359
                    if (queryResults == InvalidObject.instance) {
361
                    if (queryResults == InvalidObject.instance) {
Lines 373-378 Link Here
373
                    return results;
375
                    return results;
374
                }
376
                }
375
            }
377
            }
378
            session.incrementProfile(SessionProfiler.CacheMisses, this);
376
        }
379
        }
377
        if (QueryMonitor.shouldMonitor()) {
380
        if (QueryMonitor.shouldMonitor()) {
378
            QueryMonitor.incrementReadAllMisses(this);
381
            QueryMonitor.incrementReadAllMisses(this);
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/ReadObjectQuery.java (-7 / +12 lines)
Lines 28-33 Link Here
28
import org.eclipse.persistence.descriptors.DescriptorQueryManager;
28
import org.eclipse.persistence.descriptors.DescriptorQueryManager;
29
import org.eclipse.persistence.exceptions.*;
29
import org.eclipse.persistence.exceptions.*;
30
import org.eclipse.persistence.expressions.*;
30
import org.eclipse.persistence.expressions.*;
31
import org.eclipse.persistence.sessions.SessionProfiler;
31
import org.eclipse.persistence.sessions.remote.*;
32
import org.eclipse.persistence.sessions.remote.*;
32
import org.eclipse.persistence.tools.profiler.QueryMonitor;
33
import org.eclipse.persistence.tools.profiler.QueryMonitor;
33
34
Lines 251-267 Link Here
251
252
252
                // check locking.  If clone has not been locked, do not early return cached object
253
                // check locking.  If clone has not been locked, do not early return cached object
253
                if (isLockQuery() && (session.isUnitOfWork() && !((UnitOfWorkImpl)session).isPessimisticLocked(cachedObject))) {
254
                if (isLockQuery() && (session.isUnitOfWork() && !((UnitOfWorkImpl)session).isPessimisticLocked(cachedObject))) {
254
                    if (QueryMonitor.shouldMonitor()) {
255
                        QueryMonitor.incrementReadObjectMisses(this);
256
                    }
257
                    return null;
255
                    return null;
258
                }
256
                }
259
                if (QueryMonitor.shouldMonitor()) {
257
                if (QueryMonitor.shouldMonitor()) {
260
                    QueryMonitor.incrementReadObjectHits(this);
258
                    QueryMonitor.incrementReadObjectHits(this);
261
                }
259
                }
260
                session.incrementProfile(SessionProfiler.CacheHits, this);
262
            } else {
261
            } else {
263
                if (QueryMonitor.shouldMonitor()) {
262
                if (!session.isUnitOfWork()) {
264
                    QueryMonitor.incrementReadObjectMisses(this);
263
                    if (QueryMonitor.shouldMonitor()) {
264
                        QueryMonitor.incrementReadObjectMisses(this);
265
                    }
266
                    session.incrementProfile(SessionProfiler.CacheMisses, this);
265
                }
267
                }
266
            }
268
            }
267
            if (shouldUseWrapperPolicy()) {
269
            if (shouldUseWrapperPolicy()) {
Lines 269-276 Link Here
269
            }            
271
            }            
270
            return cachedObject;
272
            return cachedObject;
271
        } else {
273
        } else {
272
            if (QueryMonitor.shouldMonitor()) {
274
            if (!session.isUnitOfWork()) {
273
                QueryMonitor.incrementReadObjectMisses(this);
275
                if (QueryMonitor.shouldMonitor()) {
276
                    QueryMonitor.incrementReadObjectMisses(this);
277
                }
278
                session.incrementProfile(SessionProfiler.CacheMisses, this);
274
            }
279
            }
275
            return null;
280
            return null;
276
        }
281
        }
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/sequencing/QuerySequence.java (+6 lines)
Lines 215-224 Link Here
215
        if (getSelectQuery() == null) {
215
        if (getSelectQuery() == null) {
216
            setSelectQuery(buildSelectQuery());
216
            setSelectQuery(buildSelectQuery());
217
            wasSelectQueryCreated = getSelectQuery() != null;
217
            wasSelectQueryCreated = getSelectQuery() != null;
218
            if (wasSelectQueryCreated) {
219
                getSelectQuery().setName(getName());
220
            }
218
        }
221
        }
219
        if ((getUpdateQuery() == null) && !shouldSkipUpdate()) {
222
        if ((getUpdateQuery() == null) && !shouldSkipUpdate()) {
220
            setUpdateQuery(buildUpdateQuery());
223
            setUpdateQuery(buildUpdateQuery());
221
            wasUpdateQueryCreated = getUpdateQuery() != null;
224
            wasUpdateQueryCreated = getUpdateQuery() != null;
225
            if (wasUpdateQueryCreated) {
226
                getUpdateQuery().setName(getName());
227
            }
222
        }
228
        }
223
    }
229
    }
224
230
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/sequencing/Sequence.java (+1 lines)
Lines 59-64 Link Here
59
    
59
    
60
    public Sequence() {
60
    public Sequence() {
61
        super();
61
        super();
62
        setName("SEQUENCE");
62
    }
63
    }
63
64
64
    /**
65
    /**
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/sessions/server/ConnectionPool.java (-2 / +7 lines)
Lines 25-30 Link Here
25
 * @see ServerSession
25
 * @see ServerSession
26
 */
26
 */
27
public class ConnectionPool {
27
public class ConnectionPool {
28
    protected static final String MONITOR_HEADER = "Info:ConnectionPool:";
29
    
28
    protected boolean isConnected;
30
    protected boolean isConnected;
29
    protected int maxNumberOfConnections;
31
    protected int maxNumberOfConnections;
30
    protected int minNumberOfConnections;
32
    protected int minNumberOfConnections;
Lines 96-101 Link Here
96
            if ((this.connectionsUsed.size() + this.connectionsAvailable.size()) < this.maxNumberOfConnections) {
98
            if ((this.connectionsUsed.size() + this.connectionsAvailable.size()) < this.maxNumberOfConnections) {
97
                Accessor connection = buildConnection();
99
                Accessor connection = buildConnection();
98
                this.connectionsUsed.add(connection);
100
                this.connectionsUsed.add(connection);
101
                if (this.owner.isInProfile()) {
102
                    this.owner.updateProfile(MONITOR_HEADER + this.name, Integer.valueOf(this.connectionsUsed.size()));
103
                }
99
                return connection;
104
                return connection;
100
            }
105
            }
101
            try {
106
            try {
Lines 140-146 Link Here
140
        }
145
        }
141
        this.connectionsUsed.add(connection);
146
        this.connectionsUsed.add(connection);
142
        if (this.owner.isInProfile()) {
147
        if (this.owner.isInProfile()) {
143
            this.owner.updateProfile(this.name, Integer.valueOf(this.connectionsUsed.size()));
148
            this.owner.updateProfile(MONITOR_HEADER + this.name, Integer.valueOf(this.connectionsUsed.size()));
144
        }
149
        }
145
        return connection;
150
        return connection;
146
    }
151
    }
Lines 279-285 Link Here
279
            }
284
            }
280
        }
285
        }
281
        if (this.owner.isInProfile()) {
286
        if (this.owner.isInProfile()) {
282
            this.owner.updateProfile(this.name, Integer.valueOf(this.connectionsUsed.size()));
287
            this.owner.updateProfile(MONITOR_HEADER + this.name, Integer.valueOf(this.connectionsUsed.size()));
283
        }
288
        }
284
        notify();
289
        notify();
285
    }
290
    }
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/sessions/SessionProfiler.java (-66 / +47 lines)
Lines 27-99 Link Here
27
    public static final int HEAVY = 10;
27
    public static final int HEAVY = 10;
28
    public static final int ALL = Integer.MAX_VALUE;
28
    public static final int ALL = Integer.MAX_VALUE;
29
29
30
    //nouns type display name 
30
    // Sensors display name
31
    public static final String TopLinkRootNoun = "/TopLink";
31
    public static final String SessionName = "Info:SessionName";
32
    public static final String SessionNounType = "TopLink Session";
32
    public static final String LoginTime = "Info:LoginTime";
33
    public static final String TransactionNounType = "TopLink Transaction";
33
    public static final String RcmStatus = "Info:CacheCoordinationStatus";
34
    public static final String QueryNounType = "TopLink Queries";
34
    public static final String CachedObjects = "Info:CachedObjects";//TODO
35
    public static final String RcmNounType = "TopLink RCM";
35
    
36
    public static final String ConnectionNounType = "TopLink Connections";
36
    public static final String ClientSessionCreated = "Counter:ClientSessionCreates";
37
    public static final String CacheNounType = "TopLink Cache";
37
    public static final String UowCreated = "Counter:UnitOfWorkCreates";
38
    public static final String MiscellaneousNounType = "TopLink Miscellaneous";
38
    public static final String UowCommits = "Counter:UnitOfWorkCommits";
39
    public static final String UowRollbacks = "Counter:UnitOfWorkRollbacks";
40
    public static final String OptimisticLockException = "Counter:OptimisticLocks";
41
    public static final String RcmReceived = "Counter:MessagesReceived";
42
    public static final String RcmSent = "Counter:MessagesSent";
43
    public static final String RemoteChangeSet = "Counter:RemoteChangeSets";
44
    public static final String Connects = "Counter:ConnectCalls";
45
    public static final String Disconnects = "Counter:DisconnectCalls";
46
    public static final String CacheHits = "Counter:CacheHits";
47
    public static final String CacheMisses = "Counter:CacheMisses";
48
    public static final String ChangeSetsProcessed = "Counter:ChangesProcessed";
49
    public static final String ChangeSetsNotProcessed = "Counter:ChangesNotProcessed";
50
    
51
    public static final String DescriptorEvent = "Timer:DescriptorEvents";
52
    public static final String SessionEvent = "Timer:SessionEvents";
53
    public static final String QueryPreparation = "Timer:QueryPreparation";
54
    public static final String SqlGeneration = "Timer:SqlGeneration";
55
    public static final String SqlPrepare = "Timer:SqlPrepare";
56
    public static final String StatementExecute = "Timer:StatementExecute";
57
    public static final String RowFetch = "Timer:RowFetch";
58
    public static final String ObjectBuilding = "Timer:ObjectBuilding";
59
    public static final String Register = "Timer:Register";
60
    public static final String Merge = "Timer:Merge";
61
    public static final String DistributedMerge = "Timer:DistributedMerge";
62
    public static final String AssignSequence = "Timer:Sequencing";
63
    public static final String Caching = "Timer:Caching";
64
    public static final String ConnectionManagement = "Timer:ConnectionManagement";
65
    public static final String Logging = "Timer:Logging";
66
    public static final String JtsBeforeCompletion = "Timer:TXBeforeCompletion";
67
    public static final String JtsAfterCompletion = "Timer:TXAfterCompletion";
68
    public static final String Transaction = "Timer:Transactions";
69
    public static final String UowCommit = "Timer:UnitOfWorkCommit";
70
    public static final String ConnectionPing = "Timer:ConnectionPing";
39
71
40
    //dms sensors display name
41
    public static final String SessionName = "SessionName";
42
    public static final String LoginTime = "loginTime";
43
    public static final String ClientSessionCreated = "ClientSession";
44
    public static final String UowCreated = "UnitOfWork";
45
    public static final String UowCommit = "UnitOfWorkCommits";
46
    public static final String UowRollbacks = "UnitOfWorkRollbacks";
47
    public static final String OptimisticLockException = "OptimisticLocks";
48
    public static final String RcmStatus = "RCMStatus";
49
    public static final String RcmReceived = "MessagesReceived";
50
    public static final String RcmSent = "MessagesSent";
51
    public static final String RemoteChangeSet = "RemoteChangeSets";
52
    public static final String TlConnects = "ConnectCalls";
53
    public static final String TlDisconnects = "DisconnectCalls";
54
    public static final String CachedObjects = "CachedObjects";
55
    public static final String CacheHits = "CacheHits";
56
    public static final String CacheMisses = "CacheMisses";
57
    public static final String ChangeSetsProcessed = "ChangesProcessed";
58
    public static final String ChangeSetsNotProcessed = "ChangesNotProcessed";
59
    public static final String DescriptorEvent = "DescriptorEvents";
60
    public static final String SessionEvent = "SessionEvents";
61
    public static final String ConnectionInUse = "ConnectionsInUse";
62
    public static final String QueryPreparation = "QueryPreparation";
63
    public static final String SqlGeneration = "SqlGeneration";
64
    public static final String DatabaseExecute = "DatabaseExecute";
65
    public static final String SqlPrepare = "SqlPrepare";
66
    public static final String RowFetch = "RowFetch";
67
    public static final String ObjectBuilding = "ObjectBuilding";
68
    public static final String MergeTime = "MergeTime";
69
    public static final String UnitOfWorkRegister = "UnitOfWorkRegister";
70
    public static final String DistributedMergeDmsDisplayName = "DistributedMerge";
71
    public static final String Sequencing = "Sequencing";
72
    public static final String Caching = "Caching";
73
    public static final String ConnectionManagement = "ConnectionManagement";
74
    public static final String LoggingDMSDisPlayName = "Logging";
75
    public static final String JtsBeforeCompletion = "TXBeforeCompletion";
76
    public static final String JtsAfterCompletion = "TXAfterCompletion";
77
    public static final String ConnectionPing = "ConnectionHealthTest";
78
79
    //Token used by existed default performance profiler 
80
    public static final String Register = "register";
81
    public static final String Merge = "merge";
82
    public static final String AssignSequence = "assign sequence";
83
    public static final String DistributedMerge = "distributed merge";
84
    public static final String DeletedObject = "deleted object";
85
    public static final String Wrapping = "wrapping";
86
    public static final String Logging = "logging";
87
    public static final String OBJECT_BUILDING = "object building";
88
    public static final String SQL_GENERATION = "sql generation";
89
    public static final String QUERY_PREPARE = "query prepare";
90
    public static final String STATEMENT_EXECUTE = "sql execute";
91
    public static final String ROW_FETCH = "row fetch";
92
    public static final String SQL_PREPARE = "sql prepare";
93
    public static final String TRANSACTION = "transactions";
94
    public static final String CONNECT = "connect";
95
    public static final String CACHE = "cache";
96
97
    /**
72
    /**
98
     * INTERNAL:
73
     * INTERNAL:
99
     * End the operation timing.
74
     * End the operation timing.
Lines 145-150 Link Here
145
     * Increase DMS Event sensor occurrence.(DMS)
120
     * Increase DMS Event sensor occurrence.(DMS)
146
     */
121
     */
147
    public void occurred(String operationName);
122
    public void occurred(String operationName);
123
    
124
    /**
125
     * INTERNAL:
126
     * Increase DMS Event sensor occurrence.(DMS)
127
     */
128
    public void occurred(String operationName, DatabaseQuery query);
148
129
149
    /**
130
    /**
150
     * INTERNAL:
131
     * INTERNAL:
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/tools/profiler/PerformanceMonitor.java (+270 lines)
Line 0 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Oracle. All rights reserved.
3
 * This program and the accompanying materials are made available under the 
4
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 
5
 * which accompanies this distribution. 
6
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7
 * and the Eclipse Distribution License is available at 
8
 * http://www.eclipse.org/org/documents/edl-v10.php.
9
 *
10
 * Contributors:
11
 *     James Sutherland (Oracle) - initial API and implementation
12
 ******************************************************************************/  
13
package org.eclipse.persistence.tools.profiler;
14
15
import java.text.NumberFormat;
16
import java.util.*;
17
import java.io.*;
18
19
import org.eclipse.persistence.queries.*;
20
import org.eclipse.persistence.sessions.Record;
21
import org.eclipse.persistence.sessions.SessionProfiler;
22
import org.eclipse.persistence.internal.sessions.AbstractRecord;
23
import org.eclipse.persistence.internal.sessions.AbstractSession;
24
25
/**
26
 * <p><b>Purpose</b>: A tool used to provide performance monitoring information in a server environment.
27
 *
28
 * @since EclipseLink 2.2
29
 * @author James Sutherland
30
 */
31
public class PerformanceMonitor implements Serializable, Cloneable, SessionProfiler {
32
    protected static final String COUNTER = "Counter:";
33
    protected static final String TIMER = "Timer:";
34
    
35
    transient protected AbstractSession session;
36
    protected Map<String, Object> operationTimings;
37
    protected Map<Integer, Map<String, Long>> operationStartTimesByThread;//facilitates concurrency
38
    protected long lastDumpTime;
39
    protected long dumpTime;
40
    protected int profileWeight;
41
42
    /**
43
     * PUBLIC:
44
     * Create a new profiler.
45
     * The profiler can be registered with a session to log performance information on queries.
46
     */
47
    public PerformanceMonitor() {
48
        this.operationTimings = new Hashtable();
49
        this.operationStartTimesByThread = new Hashtable();
50
        this.lastDumpTime = System.currentTimeMillis();
51
        this.dumpTime = 60000; // 1 minute
52
        this.profileWeight = SessionProfiler.ALL;
53
    }
54
55
    /**
56
     * Return the number of milliseconds after which the monitor results should be logged.
57
     */
58
    public long getDumpTime() {
59
        return dumpTime;
60
    }
61
62
    /**
63
     * Set the number of milliseconds after which the monitor results should be logged.
64
     */
65
    public void setDumpTime(long dumpTime) {
66
        this.dumpTime = dumpTime;
67
    }
68
    
69
    public PerformanceMonitor clone() {
70
        try {
71
            return (PerformanceMonitor)super.clone();
72
        } catch (CloneNotSupportedException exception) {
73
            throw new InternalError();
74
        }
75
    }
76
    
77
    /**
78
     * Log the results after a set amount of time has passed.
79
     */
80
    public void checkDumpTime() {
81
        if ((System.currentTimeMillis() - this.lastDumpTime) > this.dumpTime) {
82
            dumpResults();
83
        }
84
    }
85
    
86
    /**
87
     * Log the results to the session's log (System.out).
88
     */
89
    public void dumpResults() {
90
        this.lastDumpTime = System.currentTimeMillis();
91
        StringWriter writer = new StringWriter();
92
        writer.write("\nPerformance Monitor:");
93
        writer.write(String.valueOf(this.lastDumpTime));
94
        writer.write("\nOperation\tValue (ns)\n");
95
        Set<String> operations = new TreeSet<String>(this.operationTimings.keySet());
96
        NumberFormat formater = NumberFormat.getInstance();
97
        for (String operation : operations) {
98
            Object value = this.operationTimings.get(operation);
99
            if (value == null) {
100
                value = Long.valueOf(0);
101
            }
102
            writer.write(operation);
103
            writer.write("\t");
104
            if (value instanceof Long) {
105
                writer.write(formater.format(value));
106
            } else {
107
                writer.write(value.toString());
108
            }
109
            writer.write("\n");
110
        }
111
        try {
112
            this.session.getLog().write(writer.toString());
113
            this.session.getLog().flush();
114
        } catch (IOException error) {
115
            // ignore
116
        }
117
    }
118
119
    /**
120
     * INTERNAL:
121
     * End the operation timing.
122
     */
123
    public void endOperationProfile(String operationName) {
124
        if (this.profileWeight < SessionProfiler.HEAVY) {
125
            return;
126
        }
127
        long endTime = System.nanoTime();
128
        Long startTime = getOperationStartTimes().get(operationName);
129
        if (startTime == null) {
130
            return;
131
        }
132
        long time = endTime - startTime.longValue();
133
134
        synchronized (this.operationTimings) {
135
            Long totalTime = (Long)this.operationTimings.get(operationName);
136
            if (totalTime == null) {
137
                this.operationTimings.put(operationName, Long.valueOf(time));
138
            } else {
139
                this.operationTimings.put(operationName, Long.valueOf(totalTime.longValue() + time));
140
            }
141
        }
142
    }
143
144
    /**
145
     * INTERNAL:
146
     * End the operation timing.
147
     */
148
    public void endOperationProfile(String operationName, DatabaseQuery query, int weight) {
149
        if (this.profileWeight < weight) {
150
            return;
151
        }
152
        endOperationProfile(operationName);
153
        endOperationProfile(TIMER + query.getMonitorName() + ":" + operationName.substring(TIMER.length(), operationName.length()));
154
    }
155
156
    protected Map<String, Long> getOperationStartTimes() {
157
        Integer threadId = Integer.valueOf(Thread.currentThread().hashCode());
158
        Map<String, Long> times = this.operationStartTimesByThread.get(threadId);
159
        if (times == null) {
160
            times = new Hashtable<String, Long>();
161
            this.operationStartTimesByThread.put(threadId, times);
162
        }
163
        return times;
164
    }
165
166
    protected Map<Integer, Map<String, Long>> getOperationStartTimesByThread() {
167
        return operationStartTimesByThread;
168
    }
169
170
    protected Map<String, Object> getOperationTimings() {
171
        return operationTimings;
172
    }
173
174
    public AbstractSession getSession() {
175
        return session;
176
    }
177
178
    /**
179
     * INTERNAL:
180
     * Monitoring is done on the endOperation only.
181
     */
182
    public Object profileExecutionOfQuery(DatabaseQuery query, Record row, AbstractSession session) {
183
        if (this.profileWeight < SessionProfiler.HEAVY) {
184
            return session.internalExecuteQuery(query, (AbstractRecord)row);
185
        }
186
        startOperationProfile(TIMER + query.getMonitorName());
187
        startOperationProfile(TIMER + query.getClass().getSimpleName());
188
        occurred(COUNTER + query.getClass().getSimpleName());
189
        occurred(COUNTER + query.getMonitorName());
190
        try {
191
            return session.internalExecuteQuery(query, (AbstractRecord)row);
192
        } finally {
193
            endOperationProfile(TIMER + query.getMonitorName());
194
            endOperationProfile(TIMER + query.getClass().getSimpleName());
195
            checkDumpTime();
196
        }
197
    }
198
199
    public void setSession(org.eclipse.persistence.sessions.Session session) {
200
        this.session = (AbstractSession)session;
201
    }
202
203
    /**
204
     * INTERNAL:
205
     * Start the operation timing.
206
     */
207
    public void startOperationProfile(String operationName) {
208
        getOperationStartTimes().put(operationName, Long.valueOf(System.nanoTime()));
209
    }
210
211
    /**
212
     * INTERNAL:
213
     * Start the operation timing.
214
     */
215
    public void startOperationProfile(String operationName, DatabaseQuery query, int weight) {
216
        if (this.profileWeight < weight) {
217
            return;
218
        }
219
        startOperationProfile(operationName);
220
        startOperationProfile(TIMER + query.getMonitorName() + ":" + operationName.substring(TIMER.length(), operationName.length()));
221
    }
222
223
    public void update(String operationName, Object value) {
224
        this.operationTimings.put(operationName, value);
225
    }
226
227
    public void occurred(String operationName) {
228
        if (this.profileWeight < SessionProfiler.NORMAL) {
229
            return;
230
        }
231
        synchronized (this.operationTimings) {
232
            Long occurred = (Long)this.operationTimings.get(operationName);
233
            if (occurred == null) {
234
                this.operationTimings.put(operationName, Long.valueOf(1));
235
            } else {
236
                this.operationTimings.put(operationName, Long.valueOf(occurred.longValue() + 1));
237
            }
238
        }
239
    }
240
241
    public void occurred(String operationName, DatabaseQuery query) {
242
        if (this.profileWeight < SessionProfiler.NORMAL) {
243
            return;
244
        }
245
        occurred(operationName);
246
        occurred(COUNTER + query.getMonitorName() + ":" + operationName.substring(COUNTER.length(), operationName.length()));
247
    }
248
249
    /**
250
     * Set the level of profiling.
251
     * One of ALL, HEAVY, NORMAL, NONE.
252
     * The higher the level, the more operations are profiled.
253
     * @see SessiobProfiler
254
     */
255
    public void setProfileWeight(int profileWeight) {
256
        this.profileWeight = profileWeight;
257
    }
258
259
    /**
260
     * Return the level of profiling.
261
     * One of ALL, HEAVY, NORMAL, NONE.
262
     * @see SessiobProfiler
263
     */
264
    public int getProfileWeight() {
265
        return profileWeight;
266
    }
267
268
    public void initialize() {
269
    }
270
}
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/tools/profiler/PerformanceProfiler.java (-94 / +88 lines)
Lines 29-44 Link Here
29
 * @author James Sutherland
29
 * @author James Sutherland
30
 */
30
 */
31
public class PerformanceProfiler implements Serializable, Cloneable, SessionProfiler {
31
public class PerformanceProfiler implements Serializable, Cloneable, SessionProfiler {
32
    protected Vector profiles;
32
    protected List<Profile> profiles;
33
    transient protected AbstractSession session;
33
    transient protected AbstractSession session;
34
    protected boolean shouldLogProfile;
34
    protected boolean shouldLogProfile;
35
    protected int nestLevel;
35
    protected int nestLevel;
36
    protected long nestTime;
36
    protected long nestTime;
37
    protected long profileTime;
37
    protected long profileTime;
38
    protected Hashtable operationTimings;
38
    protected Map<Integer, Map<String, Long>> operationTimingsByThread;//facilitates concurrency
39
    protected Hashtable operationStartTimes;
39
    protected Map<Integer, Map<String, Long>> operationStartTimesByThread;//facilitates concurrency
40
    protected Hashtable operationTimingsByThread;//facilitates concurrency
41
    protected Hashtable operationStartTimesByThread;//facilitates concurrency
42
40
43
    /**
41
    /**
44
     * PUBLIC:
42
     * PUBLIC:
Lines 92-98 Link Here
92
    }
90
    }
93
91
94
    protected void addProfile(Profile profile) {
92
    protected void addProfile(Profile profile) {
95
        getProfiles().addElement(profile);
93
        getProfiles().add(profile);
96
    }
94
    }
97
95
98
    /**
96
    /**
Lines 103-111 Link Here
103
        Profile summary = new Profile();
101
        Profile summary = new Profile();
104
        summary.setDomainClass(Void.class);
102
        summary.setDomainClass(Void.class);
105
        summary.setQueryClass(Void.class);
103
        summary.setQueryClass(Void.class);
106
        for (Enumeration enumtr = getProfiles().elements(); enumtr.hasMoreElements();) {
104
        for (Profile profile : getProfiles()) {
107
            Profile profile = (Profile)enumtr.nextElement();
108
109
            if ((summary.getShortestTime() == -1) || (profile.getTotalTime() < summary.getShortestTime())) {
105
            if ((summary.getShortestTime() == -1) || (profile.getTotalTime() < summary.getShortestTime())) {
110
                summary.setShortestTime(profile.getTotalTime());
106
                summary.setShortestTime(profile.getTotalTime());
111
            }
107
            }
Lines 141-148 Link Here
141
    public Hashtable buildProfileSummaryByClass() {
137
    public Hashtable buildProfileSummaryByClass() {
142
        Hashtable summaries = new Hashtable();
138
        Hashtable summaries = new Hashtable();
143
139
144
        for (Enumeration enumtr = getProfiles().elements(); enumtr.hasMoreElements();) {
140
        for (Profile profile : getProfiles()) {
145
            Profile profile = (Profile)enumtr.nextElement();
146
            Class domainClass = profile.getDomainClass();
141
            Class domainClass = profile.getDomainClass();
147
            if (domainClass == null) {
142
            if (domainClass == null) {
148
                domainClass = Void.class;
143
                domainClass = Void.class;
Lines 189-196 Link Here
189
    public Hashtable buildProfileSummaryByQuery() {
184
    public Hashtable buildProfileSummaryByQuery() {
190
        Hashtable summaries = new Hashtable();
185
        Hashtable summaries = new Hashtable();
191
186
192
        for (Enumeration enumtr = getProfiles().elements(); enumtr.hasMoreElements();) {
187
        for (Profile profile : getProfiles()) {
193
            Profile profile = (Profile)enumtr.nextElement();
194
            Class queryType = profile.getQueryClass();
188
            Class queryType = profile.getQueryClass();
195
            if (queryType == null) {
189
            if (queryType == null) {
196
                queryType = Void.class;
190
                queryType = Void.class;
Lines 224-237 Link Here
224
        return summaries;
218
        return summaries;
225
    }
219
    }
226
220
227
    public Object clone() {
221
    public PerformanceProfiler clone() {
228
        try {
222
        try {
229
            return super.clone();
223
            return (PerformanceProfiler)super.clone();
230
        } catch (CloneNotSupportedException exception) {
224
        } catch (CloneNotSupportedException exception) {
231
            ;//Do nothing
225
            throw new InternalError();
232
        }
226
        }
233
234
        return null;
235
    }
227
    }
236
228
237
    /**
229
    /**
Lines 248-255 Link Here
248
     * End the operation timing.
240
     * End the operation timing.
249
     */
241
     */
250
    public void endOperationProfile(String operationName) {
242
    public void endOperationProfile(String operationName) {
251
        long endTime = System.currentTimeMillis();
243
        long endTime = System.nanoTime();
252
        Long startTime = ((Long)getOperationStartTimes().get(operationName));
244
        Long startTime = getOperationStartTimes().get(operationName);
253
        if (startTime == null) {
245
        if (startTime == null) {
254
            return;
246
            return;
255
        }
247
        }
Lines 277-283 Link Here
277
            }
269
            }
278
        }
270
        }
279
271
280
        Long totalTime = (Long)getOperationTimings().get(operationName);
272
        Long totalTime = getOperationTimings().get(operationName);
281
        if (totalTime == null) {
273
        if (totalTime == null) {
282
            getOperationTimings().put(operationName, Long.valueOf(time));
274
            getOperationTimings().put(operationName, Long.valueOf(time));
283
        } else {
275
        } else {
Lines 301-334 Link Here
301
        return nestTime;
293
        return nestTime;
302
    }
294
    }
303
295
304
    protected Hashtable getOperationStartTimes() {
296
    protected Map<String, Long> getOperationStartTimes() {
305
        Integer threadId = Integer.valueOf(Thread.currentThread().hashCode());
297
        Integer threadId = Integer.valueOf(Thread.currentThread().hashCode());
306
        if (getOperationStartTimesByThread().get(threadId) == null) {
298
        if (getOperationStartTimesByThread().get(threadId) == null) {
307
            getOperationStartTimesByThread().put(threadId, new Hashtable(10));
299
            getOperationStartTimesByThread().put(threadId, new Hashtable(10));
308
        }
300
        }
309
        return (Hashtable)getOperationStartTimesByThread().get(threadId);
301
        return getOperationStartTimesByThread().get(threadId);
310
    }
302
    }
311
303
312
    protected Hashtable getOperationStartTimesByThread() {
304
    protected Map<Integer, Map<String, Long>> getOperationStartTimesByThread() {
313
        return operationStartTimesByThread;
305
        return operationStartTimesByThread;
314
    }
306
    }
315
307
316
    protected Hashtable getOperationTimings() {
308
    protected Map<String, Long> getOperationTimings() {
317
        Integer threadId = Integer.valueOf(Thread.currentThread().hashCode());
309
        Integer threadId = Integer.valueOf(Thread.currentThread().hashCode());
318
        if (getOperationTimingsByThread().get(threadId) == null) {
310
        if (getOperationTimingsByThread().get(threadId) == null) {
319
            getOperationTimingsByThread().put(threadId, new Hashtable(10));
311
            getOperationTimingsByThread().put(threadId, new Hashtable(10));
320
        }
312
        }
321
        return (Hashtable)getOperationTimingsByThread().get(threadId);
313
        return getOperationTimingsByThread().get(threadId);
322
    }
314
    }
323
315
324
    protected Hashtable getOperationTimingsByThread() {
316
    protected Map<Integer, Map<String, Long>> getOperationTimingsByThread() {
325
        return operationTimingsByThread;
317
        return operationTimingsByThread;
326
    }
318
    }
327
319
328
    /**
320
    /**
329
     * Return the profiles logged in this profiler.
321
     * Return the profiles logged in this profiler.
330
     */
322
     */
331
    public Vector getProfiles() {
323
    public List<Profile> getProfiles() {
332
        return profiles;
324
        return profiles;
333
    }
325
    }
334
326
Lines 407-413 Link Here
407
     * @return the execution result of the query.
399
     * @return the execution result of the query.
408
     */
400
     */
409
    public Object profileExecutionOfQuery(DatabaseQuery query, Record row, AbstractSession session) {
401
    public Object profileExecutionOfQuery(DatabaseQuery query, Record row, AbstractSession session) {
410
        long profileStartTime = System.currentTimeMillis();
402
        long profileStartTime = System.nanoTime();
411
        long nestedProfileStartTime = getProfileTime();
403
        long nestedProfileStartTime = getProfileTime();
412
        Profile profile = new Profile();
404
        Profile profile = new Profile();
413
        profile.setQueryClass(query.getClass());
405
        profile.setQueryClass(query.getClass());
Lines 424-497 Link Here
424
416
425
            setNestLevel(getNestLevel() + 1);
417
            setNestLevel(getNestLevel() + 1);
426
            long startNestTime = getNestTime();
418
            long startNestTime = getNestTime();
427
            Hashtable timingsBeforeExecution = (Hashtable)getOperationTimings().clone();
419
            Map<String, Long> timingsBeforeExecution = (Map<String, Long>)((Hashtable)getOperationTimings()).clone();
428
            Hashtable startTimingsBeforeExecution = (Hashtable)getOperationStartTimes().clone();
420
            Map<String, Long> startTimingsBeforeExecution = (Map<String, Long>)((Hashtable)getOperationStartTimes()).clone();
429
            long startTime = System.currentTimeMillis();
421
            long startTime = System.nanoTime();
430
            result = session.internalExecuteQuery(query, (AbstractRecord)row);
422
            try {
431
            long endTime = System.currentTimeMillis();
423
                result = session.internalExecuteQuery(query, (AbstractRecord)row);
432
            setNestLevel(getNestLevel() - 1);
424
                return result;
433
425
            } finally {
434
            for (Enumeration operationNames = getOperationTimings().keys();
426
                long endTime = System.nanoTime();
435
                     operationNames.hasMoreElements();) {
427
                setNestLevel(getNestLevel() - 1);
436
                String name = (String)operationNames.nextElement();
428
    
437
                Long operationStartTime = (Long)timingsBeforeExecution.get(name);
429
                for (String name : getOperationTimings().keySet()) {
438
                long operationEndTime = ((Long)getOperationTimings().get(name)).longValue();
430
                    Long operationStartTime = timingsBeforeExecution.get(name);
439
                long operationTime;
431
                    long operationEndTime = getOperationTimings().get(name).longValue();
440
                if (operationStartTime != null) {
432
                    long operationTime;
441
                    operationTime = operationEndTime - operationStartTime.longValue();
433
                    if (operationStartTime != null) {
434
                        operationTime = operationEndTime - operationStartTime.longValue();
435
                    } else {
436
                        operationTime = operationEndTime;
437
                    }
438
                    profile.addTiming(name, operationTime);
439
                }
440
    
441
                profile.setTotalTime((endTime - startTime) - (getProfileTime() - nestedProfileStartTime));// Remove the profile time from the total time.;);
442
                profile.setLocalTime(profile.getTotalTime() - (getNestTime() - startNestTime));
443
                if (result instanceof Collection) {
444
                    profile.setNumberOfInstancesEffected(((Collection)result).size());
442
                } else {
445
                } else {
443
                    operationTime = operationEndTime;
446
                    profile.setNumberOfInstancesEffected(1);
444
                }
447
                }
445
                profile.addTiming(name, operationTime);
448
    
446
            }
449
                addProfile(profile);
447
450
                if (shouldLogProfile()) {
448
            profile.setTotalTime((endTime - startTime) - (getProfileTime() - nestedProfileStartTime));// Remove the profile time from the total time.;);
451
                    writeNestingTabs(writer);
449
            profile.setLocalTime(profile.getTotalTime() - (getNestTime() - startNestTime));
452
                    long profileEndTime = System.nanoTime();
450
            if (result instanceof Vector) {
453
                    long totalTimeIncludingProfiling = profileEndTime - profileStartTime;// Try to remove the profiling time from the total time.
451
                profile.setNumberOfInstancesEffected(((Vector)result).size());
454
                    profile.setProfileTime(totalTimeIncludingProfiling - profile.getTotalTime());
452
            } else {
455
                    profile.write(writer, this);
453
                profile.setNumberOfInstancesEffected(1);
456
                    writer.write(Helper.cr());
454
            }
457
                    writeNestingTabs(writer);
455
458
                    writer.write("}" + ToStringLocalization.buildMessage("end_profile", (Object[])null));
456
            addProfile(profile);
459
                    writer.write(Helper.cr());
457
            if (shouldLogProfile()) {
460
                    writer.flush();
458
                writeNestingTabs(writer);
459
                long profileEndTime = System.currentTimeMillis();
460
                long totalTimeIncludingProfiling = profileEndTime - profileStartTime;// Try to remove the profiling time from the total time.
461
                profile.setProfileTime(totalTimeIncludingProfiling - profile.getTotalTime());
462
                profile.write(writer, this);
463
                writer.write(Helper.cr());
464
                writeNestingTabs(writer);
465
                writer.write("}" + ToStringLocalization.buildMessage("end_profile", (Object[])null));
466
                writer.write(Helper.cr());
467
                writer.flush();
468
            }
469
470
            if (getNestLevel() == 0) {
471
                setNestTime(0);
472
                setProfileTime(0);
473
                setOperationTimings(new Hashtable(5));
474
                setOperationStartTimes(new Hashtable(5));
475
                long profileEndTime = System.currentTimeMillis();
476
                long totalTimeIncludingProfiling = profileEndTime - profileStartTime;// Try to remove the profiling time from the total time.
477
                profile.setProfileTime(totalTimeIncludingProfiling - profile.getTotalTime());
478
            } else {
479
                setNestTime(startNestTime + profile.getTotalTime());
480
                setOperationTimings(timingsBeforeExecution);
481
                setOperationStartTimes(startTimingsBeforeExecution);
482
                long profileEndTime = System.currentTimeMillis();
483
                long totalTimeIncludingProfiling = profileEndTime - profileStartTime;// Try to remove the profiling time from the total time.
484
                setProfileTime(getProfileTime() + (totalTimeIncludingProfiling - (endTime - startTime)));
485
                profile.setProfileTime(totalTimeIncludingProfiling - profile.getTotalTime());
486
                for (Enumeration timingsEnum = ((Hashtable)startTimingsBeforeExecution.clone()).keys();
487
                         timingsEnum.hasMoreElements();) {
488
                    String timingName = (String)timingsEnum.nextElement();
489
                    startTimingsBeforeExecution.put(timingName, Long.valueOf(((Number)startTimingsBeforeExecution.get(timingName)).longValue() + totalTimeIncludingProfiling));
490
                }
461
                }
462
    
463
                if (getNestLevel() == 0) {
464
                    setNestTime(0);
465
                    setProfileTime(0);
466
                    setOperationTimings(new Hashtable());
467
                    setOperationStartTimes(new Hashtable());
468
                    long profileEndTime = System.nanoTime();
469
                    long totalTimeIncludingProfiling = profileEndTime - profileStartTime;// Try to remove the profiling time from the total time.
470
                    profile.setProfileTime(totalTimeIncludingProfiling - profile.getTotalTime());
471
                } else {
472
                    setNestTime(startNestTime + profile.getTotalTime());
473
                    setOperationTimings(timingsBeforeExecution);
474
                    setOperationStartTimes(startTimingsBeforeExecution);
475
                    long profileEndTime = System.nanoTime();
476
                    long totalTimeIncludingProfiling = profileEndTime - profileStartTime;// Try to remove the profiling time from the total time.
477
                    setProfileTime(getProfileTime() + (totalTimeIncludingProfiling - (endTime - startTime)));
478
                    profile.setProfileTime(totalTimeIncludingProfiling - profile.getTotalTime());
479
                    for (String timingName : ((Map<String, Long>)(((Hashtable)startTimingsBeforeExecution).clone())).keySet()) {
480
                        startTimingsBeforeExecution.put(timingName, Long.valueOf(((Number)startTimingsBeforeExecution.get(timingName)).longValue() + totalTimeIncludingProfiling));
481
                    }
482
                }
491
            }
483
            }
492
        } catch (IOException ioe) {
484
        } catch (IOException ioe) {
493
        }
485
        }
494
495
        return result;
486
        return result;
496
    }
487
    }
497
488
Lines 503-509 Link Here
503
        this.nestTime = nestTime;
494
        this.nestTime = nestTime;
504
    }
495
    }
505
496
506
    protected void setOperationStartTimes(Hashtable operationStartTimes) {
497
    protected void setOperationStartTimes(Map<String, Long> operationStartTimes) {
507
        Integer threadId = Integer.valueOf(Thread.currentThread().hashCode());
498
        Integer threadId = Integer.valueOf(Thread.currentThread().hashCode());
508
        getOperationStartTimesByThread().put(threadId, operationStartTimes);
499
        getOperationStartTimesByThread().put(threadId, operationStartTimes);
509
    }
500
    }
Lines 512-518 Link Here
512
        this.operationStartTimesByThread = operationStartTimesByThread;
503
        this.operationStartTimesByThread = operationStartTimesByThread;
513
    }
504
    }
514
505
515
    protected void setOperationTimings(Hashtable operationTimings) {
506
    protected void setOperationTimings(Map<String, Long> operationTimings) {
516
        Integer threadId = Integer.valueOf(Thread.currentThread().hashCode());
507
        Integer threadId = Integer.valueOf(Thread.currentThread().hashCode());
517
        getOperationTimingsByThread().put(threadId, operationTimings);
508
        getOperationTimingsByThread().put(threadId, operationTimings);
518
    }
509
    }
Lines 551-557 Link Here
551
     * Start the operation timing.
542
     * Start the operation timing.
552
     */
543
     */
553
    public void startOperationProfile(String operationName) {
544
    public void startOperationProfile(String operationName) {
554
        getOperationStartTimes().put(operationName, Long.valueOf(System.currentTimeMillis()));
545
        getOperationStartTimes().put(operationName, Long.valueOf(System.nanoTime()));
555
    }
546
    }
556
547
557
    /**
548
    /**
Lines 578-583 Link Here
578
569
579
    public void occurred(String operationName) {
570
    public void occurred(String operationName) {
580
    }
571
    }
572
    
573
    public void occurred(String operationName, DatabaseQuery query) {
574
    }
581
575
582
    public void setProfileWeight(int weight) {
576
    public void setProfileWeight(int weight) {
583
    }
577
    }
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java (-2 / +9 lines)
Lines 105-110 Link Here
105
import org.eclipse.persistence.internal.security.SecurableObjectHolder;
105
import org.eclipse.persistence.internal.security.SecurableObjectHolder;
106
import org.eclipse.persistence.platform.database.converters.StructConverter;
106
import org.eclipse.persistence.platform.database.converters.StructConverter;
107
import org.eclipse.persistence.platform.server.ServerPlatformBase;
107
import org.eclipse.persistence.platform.server.ServerPlatformBase;
108
import org.eclipse.persistence.tools.profiler.PerformanceMonitor;
108
import org.eclipse.persistence.tools.profiler.PerformanceProfiler;
109
import org.eclipse.persistence.tools.profiler.PerformanceProfiler;
109
import org.eclipse.persistence.tools.profiler.QueryMonitor;
110
import org.eclipse.persistence.tools.profiler.QueryMonitor;
110
111
Lines 643-648 Link Here
643
                session.setProfiler(new PerformanceProfiler());
644
                session.setProfiler(new PerformanceProfiler());
644
                return;
645
                return;
645
            }
646
            }
647
            if (newProfilerClassName.equals(ProfilerType.PerformanceMonitor)) {
648
                session.setProfiler(new PerformanceMonitor());
649
                return;
650
            }
646
            
651
            
647
            String originalProfilerClassNamer = null;
652
            String originalProfilerClassNamer = null;
648
            if (session.getProfiler() != null) {
653
            if (session.getProfiler() != null) {
Lines 1542-1547 Link Here
1542
        while (it.hasNext()) {
1547
        while (it.hasNext()) {
1543
            Map.Entry entry = (Map.Entry)it.next();
1548
            Map.Entry entry = (Map.Entry)it.next();
1544
            String name = (String)entry.getKey();
1549
            String name = (String)entry.getKey();
1550
            String customizerClassName = (String)entry.getValue();
1545
            
1551
            
1546
            ClassDescriptor descriptor = session.getDescriptorForAlias(name);
1552
            ClassDescriptor descriptor = session.getDescriptorForAlias(name);
1547
            if (descriptor == null) {
1553
            if (descriptor == null) {
Lines 1549-1559 Link Here
1549
                    Class javaClass = findClass(name, loader);
1555
                    Class javaClass = findClass(name, loader);
1550
                    descriptor = session.getDescriptor(javaClass);
1556
                    descriptor = session.getDescriptor(javaClass);
1551
                } catch (Exception ex) {
1557
                } catch (Exception ex) {
1552
                    // Ignore exception
1558
                    throw EntityManagerSetupException.failedWhileProcessingProperty(PersistenceUnitProperties.DESCRIPTOR_CUSTOMIZER_ + name, customizerClassName, ex);
1553
                }
1559
                }
1554
            }
1560
            }
1555
            if (descriptor != null) {
1561
            if (descriptor != null) {
1556
                String customizerClassName = (String)entry.getValue();
1557
                Class customizerClass = findClassForProperty(customizerClassName, PersistenceUnitProperties.DESCRIPTOR_CUSTOMIZER_ + name, loader);
1562
                Class customizerClass = findClassForProperty(customizerClassName, PersistenceUnitProperties.DESCRIPTOR_CUSTOMIZER_ + name, loader);
1558
                try {
1563
                try {
1559
                    DescriptorCustomizer customizer = (DescriptorCustomizer)customizerClass.newInstance();
1564
                    DescriptorCustomizer customizer = (DescriptorCustomizer)customizerClass.newInstance();
Lines 1561-1566 Link Here
1561
                } catch (Exception ex) {
1566
                } catch (Exception ex) {
1562
                    throw EntityManagerSetupException.failedWhileProcessingProperty(PersistenceUnitProperties.DESCRIPTOR_CUSTOMIZER_ + name, customizerClassName, ex);
1567
                    throw EntityManagerSetupException.failedWhileProcessingProperty(PersistenceUnitProperties.DESCRIPTOR_CUSTOMIZER_ + name, customizerClassName, ex);
1563
                }
1568
                }
1569
            } else {
1570
                throw EntityManagerSetupException.failedWhileProcessingProperty(PersistenceUnitProperties.DESCRIPTOR_CUSTOMIZER_ + name, customizerClassName, null);                
1564
            }
1571
            }
1565
        }
1572
        }
1566
    }
1573
    }

Return to bug 321763