use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class ReadQuery method remoteExecute.
/**
* INTERNAL:
* Return if this is a read query.
*/
@Override
public Object remoteExecute(AbstractSession session) throws DatabaseException {
if (shouldCacheQueryResults()) {
AbstractRecord arguments = new DatabaseRecord();
if (translationRow != null) {
arguments = translationRow;
}
Object queryResults = getQueryResults(session, arguments, true);
if (queryResults != null) {
return queryResults;
}
queryResults = super.remoteExecute(session);
if (queryResults != null) {
setQueryResults(queryResults, arguments, session);
}
return queryResults;
}
return super.remoteExecute(session);
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class PLSQLStoredProcedureCall method buildOutputRow.
/**
* Translate the SQL procedure output row, into the row
* expected by the PLSQL procedure.
* This handles re-ordering parameters.
*/
@Override
public AbstractRecord buildOutputRow(CallableStatement statement, DatabaseAccessor accessor, AbstractSession session) throws SQLException {
AbstractRecord outputRow = super.buildOutputRow(statement, accessor, session);
if (!shouldBuildOutputRow) {
// fake-out Oracle executeUpdate rowCount, always 1
outputRow.put("", 1);
return outputRow;
}
// re-order elements in outputRow to conform to original indices
Vector<DatabaseField> outputRowFields = outputRow.getFields();
Vector outputRowValues = outputRow.getValues();
DatabaseRecord newOutputRow = new DatabaseRecord();
List<PLSQLargument> outArguments = getArguments(arguments, OUT);
outArguments.addAll(getArguments(arguments, INOUT));
Collections.sort(outArguments, new Comparator<PLSQLargument>() {
@Override
public int compare(PLSQLargument o1, PLSQLargument o2) {
return o1.originalIndex - o2.originalIndex;
}
});
for (PLSQLargument outArg : outArguments) {
outArg.databaseType.buildOutputRow(outArg, outputRow, newOutputRow, outputRowFields, outputRowValues);
}
return newOutputRow;
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class NojiTestSet method runQuery.
@SuppressWarnings("unchecked")
@Test
public void runQuery() {
DatabaseSession s = project.createDatabaseSession();
s.dontLogMessages();
s.login();
Vector queryArgs = new NonSynchronizedVector();
queryArgs.add("testsdfsdfasdfsdfsdfsdfsdfsdfdfsdfsdffds");
boolean worked = false;
String msg = null;
Object o = null;
try {
o = s.executeQuery("Noji", Empty.class, queryArgs);
worked = true;
} catch (Exception e) {
msg = e.getMessage();
}
assertTrue("invocation noji failed: " + msg, worked);
assertNotNull("result is supposed to be not-null", o);
Vector results = (Vector) o;
DatabaseRecord record = (DatabaseRecord) results.get(0);
BigDecimal x = (BigDecimal) record.get("X");
assertTrue("wrong x value", x.intValue() == 33);
s.logout();
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class NijioNijioTestSet method runQuery.
@SuppressWarnings("unchecked")
@Test
public void runQuery() {
DatabaseSession s = project.createDatabaseSession();
s.dontLogMessages();
s.login();
Object o = null;
Vector queryArgs = new NonSynchronizedVector();
queryArgs.add(107);
queryArgs.add(108);
queryArgs.add(1);
queryArgs.add("MERV");
boolean worked = false;
String msg = null;
try {
o = s.executeQuery("NijioNijio", Empty.class, queryArgs);
worked = true;
} catch (Exception e) {
msg = e.getMessage();
}
assertTrue("invocation NijioNijio failed: " + msg, worked);
Vector results = (Vector) o;
DatabaseRecord record = (DatabaseRecord) results.get(0);
BigDecimal y = (BigDecimal) record.get("Y");
assertTrue("wrong y value", y.intValue() == 158);
String aa = (String) record.get("AA");
assertTrue("wrong aa value", aa.equals("MERVISH"));
s.logout();
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class DatabaseQuery method rowFromArguments.
/**
* INTERNAL: Translate argumentValues into a database row.
*/
public AbstractRecord rowFromArguments(List argumentValues, AbstractSession session) throws QueryException {
List<DatabaseField> argumentFields = this.argumentFields;
// query is not prepared.
if (!isPrepared() || (argumentFields == null)) {
argumentFields = buildArgumentFields();
}
if (argumentFields.size() != argumentValues.size()) {
throw QueryException.argumentSizeMismatchInQueryAndQueryDefinition(this);
}
int argumentsSize = argumentFields.size();
AbstractRecord row = new DatabaseRecord(argumentsSize);
for (int index = 0; index < argumentsSize; index++) {
row.put(argumentFields.get(index), argumentValues.get(index));
}
return row;
}
Aggregations