Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349934 - Using PerformanceMonitor & Batch Writing will cause a NullpointerException
Summary: Using PerformanceMonitor & Batch Writing will cause a NullpointerException
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-21 07:17 EDT by Hendrik CLA
Modified: 2022-06-09 10:28 EDT (History)
3 users (show)

See Also:


Attachments
Stacktrace (6.20 KB, text/plain)
2011-06-21 07:20 EDT, Hendrik CLA
no flags Details
Proposed patch (1.84 KB, patch)
2011-07-08 12:30 EDT, David Minsky CLA
no flags Details | Diff
Updated patch (1.94 KB, patch)
2011-07-18 15:18 EDT, David Minsky CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hendrik CLA 2011-06-21 07:17:05 EDT
Build Identifier: 20110301-1815

persistence.xml

<property name="eclipselink.profiler" value="PerformanceMonitor" />
<property name="eclipselink.jdbc.batch-writing" value="JDBC" />

<property name="eclipselink.target-database" value="MySQL"/>
<property name="eclipselink.jdbc.batch-writing.size" value="1000" />
<property name="eclipselink.jdbc.native-sql" value="true" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.file" value="../logs/eclipselink.log" />
<property name="eclipselink.logging.level" value="ALL" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost?rewriteBatchedStatements=true" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="" />

Stacktrace will be appended.

Reproducible: Always

Steps to Reproduce:
1. enable JDBC batch writing
2. enable PerformanceMonitor
Comment 1 Hendrik CLA 2011-06-21 07:20:44 EDT
Created attachment 198322 [details]
Stacktrace
Comment 2 Tom Ware CLA 2011-06-23 10:33:23 EDT
From an email conversation about this bug:

The fault (on our end) seems to lie on reloading a MappedSuperclass (from XML) to an Embeddable class to create our internal metamodel.

If they annotated the mapped superclass (rather than map it in XML), it may get them by the problem. Alternatively, it would seem that the embeddable class is only annotated and if it were mapped in XML it could alleviate the problem (oddly enough).

So may it may be as simple as adding in XML

<embeddable class="blah"/>

For the embeddable classes that inherit from a mapped superclass.
Comment 3 Tom Ware CLA 2011-06-23 10:33:47 EDT
sorry.... wrong bug.
Comment 4 Tom Ware CLA 2011-06-30 15:15:11 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 5 David Minsky CLA 2011-07-08 11:48:32 EDT
Reproduced problem in trunk.
Comment 6 David Minsky CLA 2011-07-08 12:20:50 EDT
Problem exists because PerformanceMonitor >> startOperationProfile and PerformanceMonitor >> endOperationProfile assume that the passed DatabaseQuery parameter is non-null (calling getMonitorName() on the query).

This is not true in batch writing, as ParameterizedSQLBatchWritingMechanism >> prepareBatchStatements explicitly passes null for the query, leading to an NPE:

session.startOperationProfile(SessionProfiler.SqlPrepare, null, SessionProfiler.ALL);

Proposing that for a null query, the String "(none)" is used within the PerformanceProfiler, for a null DatabaseQuery.
Comment 7 David Minsky CLA 2011-07-08 12:30:22 EDT
Created attachment 199353 [details]
Proposed patch

Initial patch / talking point for resolution.
Comment 8 David Minsky CLA 2011-07-14 18:20:38 EDT
Fixed in trunk (2.4) at revision: 9732
2.3.1 checkin pending.
Comment 9 David Minsky CLA 2011-07-15 17:22:40 EDT
Checked into 2.3.1 at r9747
Comment 10 David Minsky CLA 2011-07-18 14:32:02 EDT
Re-opening, based on feedback for currently checked-in fix.
Comment 11 David Minsky CLA 2011-07-18 15:18:45 EDT
Created attachment 199860 [details]
Updated patch

Amended code.
For a null query, startOperationProfile and endOperationProfile should be started/ended (for the operation), but not for the query.
Comment 12 David Minsky CLA 2011-07-18 16:15:30 EDT
Changes checked into trunk (2.4) at revision: 9752
Comment 13 David Minsky CLA 2011-07-18 17:16:09 EDT
Changes checked into 2.3.1 at revision: 9753
Comment 14 Eclipse Webmaster CLA 2022-06-09 10:28:22 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink