org.sqlproc.engine.impl
Class SqlMappingRule

java.lang.Object
  extended by org.sqlproc.engine.impl.SqlMappingRule

public class SqlMappingRule
extends java.lang.Object

The precompiled Mapping entity for one META SQL statement. Instances of this class are created by the ANTLR parser. The grammar itself is defined in SqlMapping.g. The main runtime contracts are setQueryResultData(Object, Object[]) and setQueryResultMapping(Class, SQLQuery).

Schematically:

 SqlMappingRule = SqlMappingItem+
 
     SqlMappingItem = dbName.sqlType.javaName.javaName...
 


Field Summary
protected static org.slf4j.Logger logger
          The internal slf4j logger.
private  java.util.List<SqlMappingItem> mappings
          All sub-elements based on ANTLR grammar defined in SqlMapping.g.
 
Constructor Summary
SqlMappingRule()
          Creates a new instance.
 
Method Summary
(package private)  void addMapping(SqlMappingItem item)
          Adds a new Mapping item, which is a mapping rule for one column.
static SqlMappingRule getInstance(java.lang.String mappingStatement)
          Simple factory method (design pattern).
 void setQueryResultData(java.lang.Object resultInstance, java.lang.Object[] resultValues)
          Fills the instance of the result class with output values from the SQL query execution.
 void setQueryResultMapping(java.lang.Class<?> resultClass, org.hibernate.SQLQuery query)
          Declares a scalar query result for all Mapping rule items.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.slf4j.Logger logger
The internal slf4j logger.


mappings

private java.util.List<SqlMappingItem> mappings
All sub-elements based on ANTLR grammar defined in SqlMapping.g. Every sub-element is one Mapping item.

Constructor Detail

SqlMappingRule

SqlMappingRule()
Creates a new instance. It's used from inside ANTLR parser.

Method Detail

getInstance

public static SqlMappingRule getInstance(java.lang.String mappingStatement)
                                  throws SqlEngineException
Simple factory method (design pattern). The new instance of precompiled Mapping rule is created from the String input by the ANTLR parser.

Parameters:
mappingStatement - String representation of Mapping rule
Returns:
new instance of precompiled Mapping rule
Throws:
SqlEngineException - in the case of ANTRL parsing exception

addMapping

void addMapping(SqlMappingItem item)
Adds a new Mapping item, which is a mapping rule for one column.

Parameters:
element - the Mapping item

setQueryResultMapping

public void setQueryResultMapping(java.lang.Class<?> resultClass,
                                  org.hibernate.SQLQuery query)
Declares a scalar query result for all Mapping rule items.

Parameters:
resultClass - The class used for the return values, the SQL execution output.
query - Hibernate SQL Query instance

setQueryResultData

public void setQueryResultData(java.lang.Object resultInstance,
                               java.lang.Object[] resultValues)
Fills the instance of the result class with output values from the SQL query execution.

Parameters:
resultInstance - The instance of the result class.
resultValues - Query execution output values


Copyright © 2010. All Rights Reserved.