public interface QueryOptimizer
extends org.apache.commons.collections.Transformer
QueryOptimizer
implementation can wrap
the queries and perform various optimization functions on them. To the calling API the transformations are transparent.
<bean id="qlOptimizer_OrderSummary" class="com.neurosys.modules.etl.QueryResultArrayToEntityTransformer"> <constructor-arg value="com.neurosys.ecom.orders.domain.Order" /> <!-- type --> <constructor-arg><list> <value>id</value> <value>purchaseDate</value> <value>status</value> <value>userContactDetails</value> </list></constructor-arg> <!-- field names --> <!-- <constructor-arg><bean class="com.neurosys.etl.common.transformers.MapToCollectionTransformer" /></constructor-arg> <constructor-arg ref="orderRecordToColumnIndexMapper" /> --> <!-- Only fetch fields needed, MAP of column index from 0... mapped-to field-name or Transformer(entity). Interchangable --> <constructor-arg value="false" /> <!-- Not Inverse : Field names are inclusive not exclusive --> <property name="overrideFromClause"><value><![CDATA[ Order orders LEFT JOIN orders.transaction ]]></value></property> <property name="nestedObjectInitMap"> -- Map of field name and types key="amount" value="#{T(com.neurosys.ecom.orders.domain.Amount)}" --
</property> </bean> <bean id="allOrdersQuery" class="com.neurosys.dao.jpa.JPAQueryTransformer"> <property name="query"><value><![CDATA[ SELECT orders FROM Order orders order by orders.id desc ]]></value></property> <property name="queryIsNative" value="false" /> <property name="queryOptimizer" ref="qlOptimizer_OrderSummary" /> <property name="queryOptimizerEntityAlias" value="orders" /> </bean>
Modifier and Type | Method and Description |
---|---|
void |
morphQuery(Query query)
Allow compatibility with
Query object. |
String |
replaceEntityString(String query,
String entityAlias)
Manipulates the input Query String
|
Object |
transform(Object result)
Normalize the result.
|
String replaceEntityString(String query, String entityAlias)
query
- as raw Query StringentityAlias
- What represents the entity or Tables alias(s) in the queryvoid morphQuery(Query query)
Query
object. Many API calls may use Query instead of a direct Query String,
in this case this allows us to morph the Query object to its optimized version.query
- as QueryCopyright © 2018. All rights reserved.