use of com.sun.jdo.api.persistence.support.JDOQueryException in project Payara by payara.
the class ErrorMsg method error.
/**
* Indicates an error situation.
* @param line line number
* @param col column number
* @param msg error message
*/
public void error(int line, int col, String msg) throws JDOQueryException {
JDOQueryException ex;
if (line > 1) {
// include line and column info
Object[] args = { context, new Integer(line), new Integer(col), msg };
ex = new JDOQueryException(I18NHelper.getMessage(messages, "jqlc.errormsg.generic.msglinecolumn", // NOI18N
args));
} else if (col > 0) {
// include column info
Object[] args = { context, new Integer(col), msg };
ex = new JDOQueryException(I18NHelper.getMessage(messages, "jqlc.errormsg.generic.msgcolumn", // NOI18N
args));
} else {
Object[] args = { context, msg };
ex = new JDOQueryException(I18NHelper.getMessage(messages, "jqlc.errormsg.generic.msg", // NOI18N
args));
}
logger.throwing("jqlc.ErrorMsg", "error", ex);
throw ex;
}
use of com.sun.jdo.api.persistence.support.JDOQueryException in project Payara by payara.
the class JQLC method setClass.
/**
*/
public void setClass(Class candidateClass) {
// check valid candidate class definition
if (candidateClass == null) {
JDOQueryException ex = new JDOQueryException(I18NHelper.getMessage(messages, // NOI18N
"jqlc.jqlc.generic.nocandidateclass"));
// NOI18N
logger.throwing("jqlc.JQLC", "setClass", ex);
throw ex;
}
this.candidateClass = candidateClass;
}
use of com.sun.jdo.api.persistence.support.JDOQueryException in project Payara by payara.
the class QueryImpl method doExecute.
/**
* Internal method called by execute, executeWithArray, executeWithMap.
* - calls the code generation of the query compiler
* - flushes updates
* - executes the RetrieveDesc returned by the code generation
* - resets the compiler
*/
private Object doExecute(ParameterTable params) {
Object result = null;
RetrieveDesc rd = null;
try {
// We need to make sure that no parallel thread closes the pm =>
// try to get a shared lock for the pm. Today, the pm impl does
// not allow to promote a shared lock into a exclusive lock. Thus
// we need to get an exclusive lock here. Otherwise pm.internalFlush
// runs into a deadlock, because it tries to get a exclusive lock.
// This code need to be changed to get a ahared lock as soon as
// The next line might result in a NPE, if pm is closed or if the
// query instance was deserialized. Please note, I cannot check the
// pm and then get the lock, because the pm might be closed in
// parallel. Then subsequent uses of pm in doexecute would fail.
pm.acquireExclusiveLock();
} catch (NullPointerException npe) {
// NPE means pm is closed or query instance was serialized.
String key = (createdBySerialization ? // NOI18N
"query.queryimpl.doexecute.notboundtopm" : // NOI18N
"query.queryimpl.doexecute.pmclosed");
JDOException ex = new JDOQueryException(I18NHelper.getMessage(messages, key));
// NOI18N
logger.throwing("query.QueryImpl", "compile", ex);
throw ex;
}
try {
checkCandidates();
// call the code generation
rd = jqlc.codeGen(pm, params);
// flush changes (inserts, updates, deletes) to the datastore
flush();
if (logger.isLoggable(Logger.FINER))
// NOI18N
logger.finer("LOG_ExecuteQuery", this, params.getValues());
// Note, the RetrieveDesc returned by the code generation is null
// in the case of a query having a false filter =>
// do not go to the datastore, but return an emtpy collection
result = (rd != null) ? pm.retrieve(rd, params.getValueFetcher()) : new ArrayList();
} finally {
// Note, the following stmt needs to be replaced by
// pm.releaseSharedLock, as soon as the pm supports promoting a
// shared lock into an exclusive lock.
pm.releaseExclusiveLock();
}
return result;
}
use of com.sun.jdo.api.persistence.support.JDOQueryException in project Payara by payara.
the class ParameterTable method defineValueByName.
/**
*/
private void defineValueByName(String name, Object value) {
int index = names.indexOf(name);
if (index == -1)
throw new JDOQueryException(// NOI18N
I18NHelper.getMessage(messages, "jqlc.parametertable.definevaluebyname.undefinedparam", name));
defineValueByIndex(index, value);
}
use of com.sun.jdo.api.persistence.support.JDOQueryException in project Payara by payara.
the class ParameterTable method defineValueByIndex.
/**
*/
private void defineValueByIndex(int index, Object value) {
// index < 0 => implementation error
if (index < 0)
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"jqlc.parametertable.definevaluebyindex.wrongindex", String.valueOf(index)));
// index > type.size => too many actual parameters
if (index >= types.size())
throw new JDOQueryException(// NOI18N
I18NHelper.getMessage(messages, "jqlc.parametertable.definevaluebyindex.wrongnumberofargs"));
// check type compatibility of actual and formal parameter
Class formalType = ((Type) types.get(index)).getJavaClass();
if (!isCompatibleValue(formalType, value)) {
String actualTypeName = ((value == null) ? "<type of null>" : value.getClass().getName());
throw new JDOQueryException(// NOI18N
I18NHelper.getMessage(// NOI18N
messages, // NOI18N
"jqlc.parametertable.definevaluebyindex.typemismatch", actualTypeName, formalType.getName()));
}
// everything is ok => set the actual parameters's value
values.set(index, value);
}
Aggregations