templates.velocity.java5g.perschema.constant.vm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sql2java-generator Show documentation
Show all versions of sql2java-generator Show documentation
executable jar of sql2java generator
#parse( "schema.include.vm" )
#parse( "header.include.vm" )
#set ( $javaClassName = 'Constant' )
$codewriter.setCurrentJavaFilename($pkg, "${javaClassName}.java")
package $pkg;
#####################
#macro(defineFkConst $m_table)
#set ( $m_fkIndex = 0)
#foreach($m_foreignTable in $m_table.foreignTables)
#foreach( $m_fkName in $m_table.getFkMapNames($m_foreignTable.name) )
#set ( $m_columnsOfFk = $m_table.getForeignKeysByFkName($m_fkName) )
/** foreign key ${m_table.name}(#join($m_columnsOfFk "$e.name" ',')) TO $m_foreignTable.name */
public static final int ${m_table.asFKConst($m_fkName)} = $m_fkIndex;
#set ( $m_fkIndex = $m_fkIndex +1 )
#end
#end
#end
#####################
#macro(defineIkConst $m_table)
#set ( $m_ikIndex = 0)
#foreach($m_importedTable in $m_table.importedTables)
#foreach( $m_ikName in $m_importedTable.getFkMapNames($m_table.name) )
#set ( $m_columnsOfFk = $m_importedTable.getForeignKeysByFkName($m_ikName) )
/** imported key ${m_importedTable.name}(#join($m_columnsOfFk "$e.name" ',')) TO $m_table.name */
public static final int ${m_importedTable.asIKConst($m_ikName)} = $m_ikIndex;
#set ( $m_ikIndex = $m_ikIndex +1 )
#end
#end
#end
#####################
#macro(defineIndexConst $m_table)
#set ( $m_idxIndex = 0)
#foreach($m_index in $m_table.getIndices())
/** $m_index.table.name index (#join($m_index.getIndexColumnsList() "$e.name" ',')) */
public static final int ${m_index.asConstName()} = $m_idxIndex;
#set ( $m_idxIndex = $m_idxIndex +1 )
#end
#end
#####################
/**
* constant declare
* @author guyadong
*/
public interface $javaClassName extends gu.sql2java.Constant {
//////////////////////////////////////
// COLUMN COLUMN CONSTANT
//////////////////////////////////////
#join($tables '
public static final int ${e.name.toUpperCase()}_COLUMN_COUNT = $e.countColumns();
public static final int ${e.name.toUpperCase()}_PK_COUNT = $e.countPrimaryKeys();' '')
//////////////////////////////////////
// FOREIGN KEY INDEX DECLARE
//////////////////////////////////////
#foreach($t in $tables)
#defineFkConst($t)
#end
//////////////////////////////////////
// IMPORTED KEY INDEX DECLARE
//////////////////////////////////////
#foreach($t in $tables)
#defineIkConst($t)
#end
//////////////////////////////////////
// INDEX INDEX DECLARE
//////////////////////////////////////
#foreach($t in $tables)
#defineIndexConst($t)
#end
//////////////////////////////////////
// COLUMN ID DECLARE
//////////////////////////////////////
#foreach($t in $tables)
#foreach ( $column in $t.columns )
#set ( $vcmo = $velocityCount - 1 )
/** Identify the $column.getFullName() field (ordinal:$column.getOrdinalPosition()). */
public static final int $column.getIDConstName() = $vcmo;
#if( !$t.stateVarTypeIsArray() )
public static final ${codewriter.bitStateClassName} $column.getIDMaskConstName() = 1$!{codewriter.bitStateConstSuffix} << $vcmo;
#end
#end
#end
//////////////////////////////////////
// COLUMN NAME DECLARE
//////////////////////////////////////
#foreach($t in $tables)
/////////////////// $t.name ////////////
/** Contains all the pk fields name of the $t.name table.*/
public static final String $t.name.toUpperCase()_PK_FIELDS ="#join($t.primaryKeys '$e.name' '"
+ ",')";
public static final java.util.List $t.name.toUpperCase()_PK_FIELDS_LIST = java.util.Arrays.asList(${t.name.toUpperCase()}_PK_FIELDS.split(","));
/** Contains all the full fields of the $t.name table.*/
public static final String $t.name.toUpperCase()_FULL_FIELDS ="#join($t.columns '$e.fullName' '"
+ ",')";
/** Field that contains the comma separated fields of the $t.name table. */
public static final String $t.name.toUpperCase()_FIELDS = "#join($t.columns '$e.name' '"
+ ",')";
public static final java.util.List $t.name.toUpperCase()_FIELDS_LIST = java.util.Arrays.asList(${t.name.toUpperCase()}_FIELDS.split(","));
/** Field that contains the comma separated java fields of the $t.name table. */
public static final String $t.name.toUpperCase()_JAVA_FIELDS = "#join($t.columns '$e.varName' '"
+ ",')";
public static final java.util.List $t.name.toUpperCase()_JAVA_FIELDS_LIST = java.util.Arrays.asList(${t.name.toUpperCase()}_JAVA_FIELDS.split(","));
/** Field java types of the $t.name table. */
public static final Class>[] $t.name.toUpperCase()_FIELD_TYPES = new Class>[]{
#join($t.columns '${e.getJavaType()}.class' ',
')};
/** Field SQL types of the $t.name table. */
public static final int[] $t.name.toUpperCase()_FIELD_SQL_TYPES = new int[]{
#join($t.columns '${e.type}/*${e.javaTypeAsTypeName}*/' ',
')};
#end
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy