Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.persistence.internal.sessions.AbstractSession;
import org.eclipse.persistence.exceptions.i18n.ExceptionMessageGenerator;
import org.eclipse.persistence.sessions.DataRecord;
import org.eclipse.persistence.logging.SessionLog;

/**
* <P><B>Purpose</B>:
Expand Down Expand Up @@ -210,7 +211,7 @@ public String getMessage() {
} else {
writer.write("000");
}
if (getCall() != null) {
if (getCall() != null && session.shouldLog(SessionLog.FINE, SessionLog.SQL)) {
writer.write(cr());
writer.write(getIndentationString());
writer.write(ExceptionMessageGenerator.getHeader("CallHeader"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,10 @@ public Object executeQuery(DatabaseQuery query, AbstractRecord row, int retryCou
if (queryException.getSession() == null) {
queryException.setSession(this);
}
if (queryException.getQuery().getSession() == null) {
queryException.getQuery().setSession(this);
}
queryException.getQuery().setOccurException(true);
} else if (exception instanceof DatabaseException) {
DatabaseException databaseException = (DatabaseException)exception;
if (databaseException.getQuery() == null) {
Expand All @@ -1867,6 +1871,10 @@ public Object executeQuery(DatabaseQuery query, AbstractRecord row, int retryCou
if (databaseException.getSession() == null) {
databaseException.setSession(this);
}
if (databaseException.getQuery().getSession() == null) {
databaseException.getQuery().setSession(this);
}
databaseException.getQuery().setOccurException(true);
//if this query is a read query outside of a transaction then we may be able to retry the query
if (!isInTransaction() && query.isReadQuery() && getDatasourceLogin() instanceof DatabaseLogin) {
final int count = getLogin().getQueryRetryAttemptCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.eclipse.persistence.sessions.remote.*;
import org.eclipse.persistence.sessions.DatabaseRecord;
import org.eclipse.persistence.sessions.SessionProfiler;
import org.eclipse.persistence.logging.SessionLog;

/**
* <p>
Expand Down Expand Up @@ -336,6 +337,9 @@ public enum ParameterType {POSITIONAL, NAMED}
/** Allow the reserved pound char used to delimit bind parameters to be overridden */
protected String parameterDelimiter;

/** Flag to control the sql log */
protected boolean occurException = false;

/**
* PUBLIC: Initialize the state of the query
*/
Expand Down Expand Up @@ -2670,6 +2674,20 @@ public void storeBypassCache() {
setShouldStoreBypassCache(true);
}

/**
* Return true if exception has occured.
*/
public boolean isOccurException() {
return occurException;
}

/**
* Set if exception has occurd.
*/
public void setOccurException(boolean occurException) {
this.occurException = occurException;
}

@Override
public String toString() {
String referenceClassString = "";
Expand All @@ -2681,6 +2699,9 @@ public String toString() {
if ((getName() != null) && (!getName().equals(""))) {
nameString = "name=\"" + getName() + "\" ";
}
if (isOccurException() && !session.shouldLog(SessionLog.FINE, SessionLog.SQL)) {
return getClass().getSimpleName() + "(" + nameString + referenceClassString + ")";
}
if (isSQLCallQuery()) {
queryString = "sql=\"" + getSQLString() + "\"";
} else if (isJPQLCallQuery()) {
Expand Down