/** * Convenience method */ protected AbstractRecord getTranslationRow() { return this.query.getTranslationRow(); }
/** * Convenience method */ protected AbstractRecord getTranslationRow() { return this.query.getTranslationRow(); }
/** * Convenience method */ protected AbstractRecord getTranslationRow() { return this.query.getTranslationRow(); }
Session session = JpaHelper.getDatabaseSession(getEntityManager().getEntityManagerFactory()); DatabaseQuery databaseQuery = null; if(typedQuery instanceof EJBQueryImpl) databaseQuery = ((EJBQueryImpl<T>)typedQuery).getDatabaseQuery(); else databaseQuery = typedQuery.unwrap(JpaQuery.class).getDatabaseQuery(); sql = databaseQuery.getTranslatedSQLString(session, databaseQuery.getTranslationRow());
/** * Initialize the query-based value holder. * @param query The query that returns the object when executed. * @param row The row representation of the object. * @param mapping The mapping that is uses batch reading. */ public BatchValueHolder(ReadQuery query, AbstractRecord row, ForeignReferenceMapping mapping, DatabaseQuery originalQuery) { super(query, row, originalQuery.getSession()); this.mapping = mapping; this.argumentRow = originalQuery.getTranslationRow(); }
/** * Execute the call. It is assumed the call has been fully prepared. * @exception DatabaseException - an error has occurred on the database. */ protected Object executeCall(DatasourceCall databaseCall) throws DatabaseException { // For CR 2923 must move to session we will execute call on now // so correct DatasourcePlatform used by translate. AbstractSession sessionToUse = this.query.getExecutionSession(); DatasourceCall clonedCall = (DatasourceCall)databaseCall.clone(); clonedCall.setQuery(this.query); clonedCall.translate(this.query.getTranslationRow(), getModifyRow(), sessionToUse); return sessionToUse.executeCall(clonedCall, this.query.getTranslationRow(), this.query); }
/** * Execute the call. It is assumed the call has been fully prepared. * @exception DatabaseException - an error has occurred on the database. */ protected Object executeCall(DatasourceCall databaseCall) throws DatabaseException { // For CR 2923 must move to session we will execute call on now // so correct DatasourcePlatform used by translate. AbstractSession sessionToUse = this.query.getExecutionSession(); DatasourceCall clonedCall = (DatasourceCall)databaseCall.clone(); clonedCall.setQuery(this.query); clonedCall.translate(this.query.getTranslationRow(), getModifyRow(), sessionToUse); return sessionToUse.executeCall(clonedCall, this.query.getTranslationRow(), this.query); }
/** * Execute the call. It is assumed the call has been fully prepared. * @exception DatabaseException - an error has occurred on the database. */ protected Object executeCall(DatasourceCall databaseCall) throws DatabaseException { // For CR 2923 must move to session we will execute call on now // so correct DatasourcePlatform used by translate. AbstractSession sessionToUse = this.query.getExecutionSession(); DatasourceCall clonedCall = (DatasourceCall)databaseCall.clone(); clonedCall.setQuery(this.query); clonedCall.translate(this.query.getTranslationRow(), getModifyRow(), sessionToUse); return sessionToUse.executeCall(clonedCall, this.query.getTranslationRow(), this.query); }
/** * INTERNAL * Used to give the subclasses oportunity to copy aspects of the cloned query * to the original query. */ protected void clonedQueryExecutionComplete(DatabaseQuery query, AbstractSession session) { if (shouldCacheQueryResults()) { // Cached query results must exist on the original query rather than the cloned one setQueryResults(((ReadQuery)query).getTemporaryCachedQueryResults(), query.getTranslationRow(), query.getSession()); } }
/** * INTERNAL * Used to give the subclasses opportunity to copy aspects of the cloned query * to the original query. */ protected void clonedQueryExecutionComplete(DatabaseQuery query, AbstractSession session) { if (shouldCacheQueryResults()) { Object result = ((ReadQuery)query).getTemporaryCachedQueryResults(); // If the temporary results were never set, then don't cache null. if (result != null) { // Cached query results must exist on the original query rather than the cloned one. setQueryResults(result, query.getTranslationRow(), query.getSession()); } } }
/** * INTERNAL: * Called by prepare method only. */ @Override protected void prepareInternal(AbstractSession session) { setSQLStringInternal(session.getPlatform().buildProcedureCallString(this, session, getQuery().getTranslationRow())); super.prepareInternal(session); }
/** * INTERNAL * Used to give the subclasses opportunity to copy aspects of the cloned query * to the original query. */ protected void clonedQueryExecutionComplete(DatabaseQuery query, AbstractSession session) { if (shouldCacheQueryResults()) { Object result = ((ReadQuery)query).getTemporaryCachedQueryResults(); // If the temporary results were never set, then don't cache null. if (result != null) { // Cached query results must exist on the original query rather than the cloned one. setQueryResults(result, query.getTranslationRow(), query.getSession()); } } }
@Override protected Object executeCall(DatasourceCall databaseCall) throws DatabaseException { AbstractSession sessionToUse = this.query.getExecutionSession(); boolean doNotUseCachedInserts = Boolean.valueOf(String.valueOf(sessionToUse.getProperty("cuba.doNotUseCachedInserts"))); String cachedQuery = databaseCall.getQueryString(); if (doNotUseCachedInserts && cachedQuery != null && cachedQuery.startsWith("INSERT")) { Matcher matcher = INSERT_PATTERN.matcher(cachedQuery); if (matcher.find()) { String tableName = matcher.group(1); DatabaseTable targetTable = getDescriptor().getTable(tableName); SQLInsertStatement sqlInsertStatement = this.buildInsertStatement(targetTable); DatasourceCall call = getDescriptor().buildCallFromStatement(sqlInsertStatement, getQuery(), getExecutionSession()); call.setQuery(this.query); call.prepare(sessionToUse); call.translate(this.query.getTranslationRow(), getModifyRow(), sessionToUse); return sessionToUse.executeCall(call, this.query.getTranslationRow(), this.query); } } return super.executeCall(databaseCall); } // cuba end
/** * INTERNAL: * Called by prepare method only. */ @Override protected void prepareInternal(AbstractSession session) { setSQLStringInternal(session.getPlatform().buildProcedureCallString(this, session, getQuery().getTranslationRow())); super.prepareInternal(session); }
/** * Read all rows from the database, return ResultSet * @exception DatabaseException - an error has occurred on the database */ public DatabaseCall selectResultSet() throws DatabaseException { try { // For CR 2923 must move to session we will execute call on now // so correct DatasourcePlatform used by translate. AbstractSession sessionToUse = this.query.getExecutionSession(); DatabaseCall clonedCall = (DatabaseCall)this.call.clone(); clonedCall.setQuery(this.query); clonedCall.translate(this.query.getTranslationRow(), getModifyRow(), sessionToUse); clonedCall.returnCursor(); return (DatabaseCall)sessionToUse.executeCall(clonedCall, this.query.getTranslationRow(), this.query); } catch (java.lang.ClassCastException e) { throw QueryException.invalidDatabaseCall(this.call); } }
/** * Read all rows from the database, return ResultSet * @exception DatabaseException - an error has occurred on the database */ public DatabaseCall selectResultSet() throws DatabaseException { try { // For CR 2923 must move to session we will execute call on now // so correct DatasourcePlatform used by translate. AbstractSession sessionToUse = this.query.getExecutionSession(); DatabaseCall clonedCall = (DatabaseCall)this.call.clone(); clonedCall.setQuery(this.query); clonedCall.translate(this.query.getTranslationRow(), getModifyRow(), sessionToUse); clonedCall.returnCursor(); return (DatabaseCall)sessionToUse.executeCall(clonedCall, this.query.getTranslationRow(), this.query); } catch (java.lang.ClassCastException e) { throw QueryException.invalidDatabaseCall(this.call); } }
protected void buildAndExecuteCall(DatabaseCall dbCall, AbstractSession session) { DatabaseQuery query = dbCall.getQuery(); if (!query.isWriteObjectQuery()) { //if not writequery, should not go through the locator writing.. return; } WriteObjectQuery writeQuery = (WriteObjectQuery)query; writeQuery.setAccessor(accessor); //build a select statement form the query SQLSelectStatement selectStatement = buildSelectStatementForLocator(writeQuery, dbCall, session); //then build a call from the statement DatabaseCall call = buildCallFromSelectStatementForLocator(selectStatement, writeQuery, dbCall, session); accessor.executeCall(call, call.getQuery().getTranslationRow(), session); }
protected void buildAndExecuteCall(DatabaseCall dbCall, AbstractSession session) { DatabaseQuery query = dbCall.getQuery(); if (!query.isWriteObjectQuery()) { //if not writequery, should not go through the locator writing.. return; } WriteObjectQuery writeQuery = (WriteObjectQuery)query; writeQuery.setAccessor(accessor); //build a select statement form the query SQLSelectStatement selectStatement = buildSelectStatementForLocator(writeQuery, dbCall, session); //then build a call from the statement DatabaseCall call = buildCallFromSelectStatementForLocator(selectStatement, writeQuery, dbCall, session); accessor.executeCall(call, call.getQuery().getTranslationRow(), session); }
protected void buildAndExecuteCall(DatabaseCall dbCall, AbstractSession session) { DatabaseQuery query = dbCall.getQuery(); if (!query.isWriteObjectQuery()) { //if not writequery, should not go through the locator writing.. return; } WriteObjectQuery writeQuery = (WriteObjectQuery)query; writeQuery.setAccessor(accessor); //build a select statement form the query SQLSelectStatement selectStatement = buildSelectStatementForLocator(writeQuery, dbCall, session); //then build a call from the statement DatabaseCall call = buildCallFromSelectStatementForLocator(selectStatement, writeQuery, dbCall, session); accessor.executeCall(call, call.getQuery().getTranslationRow(), session); }
/** * INTERNAL: * Set the properties needed to be cascaded into the custom query inlucding the translation row. */ protected void prepareCustomQuery(DatabaseQuery customQuery) { ReadObjectQuery customReadQuery = (ReadObjectQuery)customQuery; customReadQuery.setShouldRefreshIdentityMapResult(shouldRefreshIdentityMapResult()); customReadQuery.setCascadePolicy(getCascadePolicy()); customReadQuery.setShouldMaintainCache(shouldMaintainCache()); customReadQuery.setShouldUseWrapperPolicy(shouldUseWrapperPolicy()); // CR... was missing some values, execution could cause infinite loop. customReadQuery.setQueryId(getQueryId()); customReadQuery.setExecutionTime(getExecutionTime()); customReadQuery.setShouldLoadResultIntoSelectionObject(shouldLoadResultIntoSelectionObject()); AbstractRecord primaryKeyRow; if (getSelectionObject() != null) { // CR#... Must also set the selection object as may be loading into the object (refresh) customReadQuery.setSelectionObject(getSelectionObject()); // The translation/primary key row will be set in prepareForExecution. } else if (getSelectionKey() != null) { customReadQuery.setSelectionKey(getSelectionKey()); } else { // The primary key row must be used. primaryKeyRow = customQuery.getDescriptor().getObjectBuilder().extractPrimaryKeyRowFromExpression(getSelectionCriteria(), customQuery.getTranslationRow(), customReadQuery.getSession()); customReadQuery.setTranslationRow(primaryKeyRow); } }