org.sqlproc.engine.impl
Class SqlMappingItem

java.lang.Object
  extended by org.sqlproc.engine.impl.SqlMappingItem
All Implemented Interfaces:
SqlMetaElement

 class SqlMappingItem
extends java.lang.Object
implements SqlMetaElement

The Mapping rule entity for one output attribute. Instance of this class is created by the ANTLR parser. The grammar itself is defined in SqlMapping.g.

Author:
Vladimir Hudec

Field Summary
private  java.lang.String dbName
          The name of a database query output - the column name or the alias name.
private  java.util.List<java.lang.String> javaNames
          The name of an attribute in the result class.
(package private)  org.slf4j.Logger logger
          The internal slf4j logger.
private  SqlType sqlType
          The type of an attribute in the result class and/or the database column type.
 
Fields inherited from interface org.sqlproc.engine.impl.SqlMetaElement
AND_PREFIX, CONST_PREFIX, IDENT_PREFIX, IDENT_PREFIX_LEN, IDENT_SEPARATOR, OR_PREFIX
 
Constructor Summary
SqlMappingItem(java.lang.String dbName)
          Creates a new instance.
 
Method Summary
(package private)  void addName(java.lang.String name)
          Adds a partial name of an attribute.
(package private)  java.lang.String getDbName()
          Returns the name of a database query output - the column name or the alias name.
(package private)  java.util.List<java.lang.String> getJavaNames()
          Returns the name of an attribute in the result class.
(package private)  SqlType getSqlType()
          Returns the type of an attribute in the result class.
(package private)  SqlMappingItem merge(SqlMappingItem outputMapping)
          Merge mapping rules for one output column based on SqlMapping.g and SqlStatement.g.
 SqlProcessResult process(SqlProcessContext ctx)
          The main contract for a dynamic ANSI SQL Query generation.
(package private)  void setHibernateType(java.lang.String sHibernateType)
          Assigns a Hibernate type.
(package private)  void setJavaNames(java.util.List<java.lang.String> javaNames)
          Sets the name of an attribute in the result class.
(package private)  void setMetaType(java.lang.String sMetaType)
          Assigns an internal type.
(package private)  void setQueryResultData(java.lang.Object resultInstance, java.lang.Object resultValue)
          Initializes the attribute of the result class with output values from SQL query execution.
 void setQueryResultMapping(java.lang.Class<?> resultClass, org.hibernate.SQLQuery query)
          Declares a scalar query result for this mapping rule item.
(package private)  void setSqlType(SqlType sqlType)
          Sets the type of an attribute in the result class.
(package private)  void setValue(java.lang.String value)
          Sets the value.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

final org.slf4j.Logger logger
The internal slf4j logger.


javaNames

private java.util.List<java.lang.String> javaNames
The name of an attribute in the result class. In the case of embedded classes the can be in fact a list of partial names (name1.name2...nameX). This name can be null. In this case the name of the attribute is the same as the name of the query column or alias output.


dbName

private java.lang.String dbName
The name of a database query output - the column name or the alias name.


sqlType

private SqlType sqlType
The type of an attribute in the result class and/or the database column type. In fact it's a pair of a Hibernate type and/or an internal type.

Constructor Detail

SqlMappingItem

SqlMappingItem(java.lang.String dbName)
Creates a new instance. It's used from inside ANTLR parser.

Parameters:
dbName - the name of a database query output - the column name or the alias name
Method Detail

getDbName

java.lang.String getDbName()
Returns the name of a database query output - the column name or the alias name.

Returns:
the name of a database query output

addName

void addName(java.lang.String name)
Adds a partial name of an attribute.

Parameters:
name - the partial name of an attribute in the result class

getJavaNames

java.util.List<java.lang.String> getJavaNames()
Returns the name of an attribute in the result class.

Returns:
the name of an attribute in the result class

setJavaNames

void setJavaNames(java.util.List<java.lang.String> javaNames)
Sets the name of an attribute in the result class.

Parameters:
javaNames - the name of an attribute in the result class

setMetaType

void setMetaType(java.lang.String sMetaType)
Assigns an internal type. This type it's used in a conversion process of SQL query output values.

Parameters:
sMetaType - String representation of an internal type for this mapping rule item

getSqlType

SqlType getSqlType()
Returns the type of an attribute in the result class.

Returns:
the type of an attribute in the result class

setSqlType

void setSqlType(SqlType sqlType)
Sets the type of an attribute in the result class.

Parameters:
sqlType - the type of an attribute in the result class

setHibernateType

void setHibernateType(java.lang.String sHibernateType)
Assigns a Hibernate type. This type it's used in a conversion process of SQL query output values.

Parameters:
sHibernateType - String representation of an Hibernate type for this mapping rule item

setValue

void setValue(java.lang.String value)
Sets the value. Right now only for the special of the enumeration type of the input value. The logical evaluation of the input value is based on the comparison to this value.

Parameters:
value - the value for special enumeration treatment

setQueryResultMapping

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

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

setQueryResultData

void setQueryResultData(java.lang.Object resultInstance,
                        java.lang.Object resultValue)
Initializes the attribute of the result class with output values from SQL query execution.

Parameters:
resultInstance - the instance of the result class
resultValue - query execution output value

merge

SqlMappingItem merge(SqlMappingItem outputMapping)
Merge mapping rules for one output column based on SqlMapping.g and SqlStatement.g. This mapping rule has the higher priority.

Parameters:
outputMapping - mapping rule based on SqlMapping.g
Returns:
a new merged mapping rule

process

public SqlProcessResult process(SqlProcessContext ctx)
The main contract for a dynamic ANSI SQL Query generation. Also known as a META SQL processing. The composite pattern main contract. All ANTLR grammar based elements must implement this contract.

Specified by:
process in interface SqlMetaElement
Parameters:
ctx - the crate for all input parameters and the context of processing

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2011. All Rights Reserved.