use of org.eclipse.persistence.queries.DatabaseQuery in project eclipselink by eclipse-ee4j.
the class JPAQuery method processSQLQuery.
/**
* INTERNAL:
* Convert the SQL string into a DatabaseQuery.
*/
public DatabaseQuery processSQLQuery(Session session) {
DatabaseQuery query = null;
ClassLoader loader = session.getDatasourcePlatform().getConversionManager().getLoader();
if (resultClassName != null) {
Class<?> clazz = session.getDatasourcePlatform().getConversionManager().convertClassNameToClass(resultClassName);
query = EJBQueryImpl.buildSQLDatabaseQuery(clazz, sqlString, hints, loader, (AbstractSession) session);
} else if (resultSetMappingNames != null) {
query = EJBQueryImpl.buildSQLDatabaseQuery(resultSetMappingNames.get(0), sqlString, hints, loader, (AbstractSession) session);
} else {
// Neither a resultClass or resultSetMapping is specified so place in a temp query on the session
query = EJBQueryImpl.buildSQLDatabaseQuery(sqlString, hints, loader, (AbstractSession) session);
}
query.setName(this.getName());
return query;
}
use of org.eclipse.persistence.queries.DatabaseQuery in project eclipselink by eclipse-ee4j.
the class JPAQuery method prepare.
/**
* INTERNAL:
* Generate the DatabaseQuery query from the JPA named query.
*/
@Override
public void prepare() {
DatabaseQuery query = null;
ClassLoader loader = session.getDatasourcePlatform().getConversionManager().getLoader();
if (isSQLQuery()) {
query = processSQLQuery(getSession());
} else if (isJPQLQuery()) {
query = processJPQLQuery(getSession());
} else if (call != null) {
query = processStoredProcedureQuery(getSession());
if (call.hasParameters()) {
// convert the type in the parameters; query.convertClassNamesToClasses does not cascade to the call
for (Object value : call.getParameters()) {
if (value instanceof Object[]) {
// must be inout type, and the out portion is a DatabaseField
((DatabaseField) ((Object[]) value)[1]).convertClassNamesToClasses(loader);
value = ((Object[]) value)[0];
}
if (value instanceof DatabaseField) {
((DatabaseField) value).convertClassNamesToClasses(loader);
}
}
}
}
// Make sure all class names have been converted.
query.convertClassNamesToClasses(loader);
setDatabaseQuery(query);
}
use of org.eclipse.persistence.queries.DatabaseQuery in project eclipselink by eclipse-ee4j.
the class StoredProcedureQueryImpl method buildResultSetMappingNameQuery.
/**
* Build a ResultSetMappingQuery from a sql result set mapping name and a
* stored procedure call.
*
* This is called from a named stored procedure that employs result set
* mapping name(s) which should be available from the session.
*/
public static DatabaseQuery buildResultSetMappingNameQuery(List<String> resultSetMappingNames, StoredProcedureCall call, Map<String, Object> hints, ClassLoader classLoader, AbstractSession session) {
// apply any query hints
DatabaseQuery hintQuery = applyHints(hints, buildResultSetMappingNameQuery(resultSetMappingNames, call), classLoader, session);
// apply any query arguments
applyArguments(call, hintQuery);
return hintQuery;
}
use of org.eclipse.persistence.queries.DatabaseQuery in project eclipselink by eclipse-ee4j.
the class StoredProcedureQueryImpl method buildStoredProcedureQuery.
/**
* Build a ReadAllQuery from a class and stored procedure call.
*/
public static DatabaseQuery buildStoredProcedureQuery(Class<?> resultClass, StoredProcedureCall call, Map<String, Object> hints, ClassLoader classLoader, AbstractSession session) {
DatabaseQuery query = new ReadAllQuery(resultClass);
query.setCall(call);
query.setIsUserDefined(true);
// apply any query hints
query = applyHints(hints, query, classLoader, session);
// apply any query arguments
applyArguments(call, query);
return query;
}
use of org.eclipse.persistence.queries.DatabaseQuery in project eclipselink by eclipse-ee4j.
the class StoredProcedureQueryImpl method buildStoredProcedureQuery.
/**
* Build a ResultSetMappingQuery from a sql result set mapping name and a
* stored procedure call.
*/
public static DatabaseQuery buildStoredProcedureQuery(String sqlResultSetMappingName, StoredProcedureCall call, Map<String, Object> hints, ClassLoader classLoader, AbstractSession session) {
ResultSetMappingQuery query = new ResultSetMappingQuery();
query.setSQLResultSetMappingName(sqlResultSetMappingName);
query.setCall(call);
query.setIsUserDefined(true);
// apply any query hints
DatabaseQuery hintQuery = applyHints(hints, query, classLoader, session);
// apply any query arguments
applyArguments(call, hintQuery);
return hintQuery;
}
Aggregations