You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by cv...@apache.org on 2005/01/23 15:05:26 UTC

cvs commit: jakarta-slide/src/conf/ojb/templates VM_global_library.vm mysql.properties mysql.vm mysql41.properties mysql41.vm oracle.properties oracle.vm postgresql.properties postgresql.vm

cvillegas    2005/01/23 06:05:26

  Added:       src/conf/ojb/templates VM_global_library.vm mysql.properties
                        mysql.vm mysql41.properties mysql41.vm
                        oracle.properties oracle.vm postgresql.properties
                        postgresql.vm
  Log:
  Velocity templates for custom SQL generator
  
  Revision  Changes    Path
  1.1                  jakarta-slide/src/conf/ojb/templates/VM_global_library.vm
  
  Index: VM_global_library.vm
  ===================================================================
  ## macros
  
  #macro( notnull $nullString $col)
  #if( $col.isNotNull() )
  #set( $nullString = $props.getProperty("NOTNULL") )
  #else
  #set( $nullString = '')
  #end
  #end
  
  #macro( printcols $res $columns )
  #set($res = '')
  #foreach($col in $columns)
  #set($res = "$res $col.name,")
  #end
  #set($res = "$strings.chop($res,1)" )
  #end
  
  
  
  1.1                  jakarta-slide/src/conf/ojb/templates/mysql.properties
  
  Index: mysql.properties
  ===================================================================
  # JDBC to MySQL mappings.
  #
  # A good MySQL resource for determining these mappings is at
  # http://www.mysql.com/doc/C/o/Column_types.html
  
  BIT = TINYINT(1)
  TINYINT = TINYINT
  SMALLINT = SMALLINT
  INTEGER = INTEGER
  BIGINT = BIGINT
  FLOAT = FLOAT
  REAL = REAL
  DOUBLE = DOUBLE
  NUMERIC = DECIMAL
  DECIMAL = DECIMAL
  CHAR = CHAR
  VARCHAR = VARCHAR
  LONGVARCHAR = MEDIUMTEXT
  DATE = DATETIME
  TIME = TIME
  TIMESTAMP = TIMESTAMP
  BINARY = BLOB
  VARBINARY = MEDIUMBLOB
  LONGVARBINARY = LONGBLOB
  NULL = NULL
  OTHER =
  JAVA_OBJECT =
  DISTINCT =
  STRUCT =
  ARRAY =
  BLOB = LONGBLOB
  CLOB = LONGTEXT
  REF =
  
  NOTNULL = NOT NULL
  
  
  
  1.1                  jakarta-slide/src/conf/ojb/templates/mysql.vm
  
  Index: mysql.vm
  ===================================================================
  # ----------------------------------------------------
  #foreach($table in $droptables)
  DROP TABLE IF EXISTS $table.name;
  #end
  
  # ----------------------------------------------------
  #foreach($table in $tables)
  CREATE TABLE $table.name (
  #set( $dec = '' )
  #foreach($col in $table.columns)
  #notnull($nullString $col)
  #if( $col.type=="TEXT" || $col.type=="MEDIUMTEXT" || $col.type=="LONGTEXT" )
  #set($size='')
  #else
  #set($size="$col.printSize()")
  #end
  #set( $dec = "$dec    $col.name  $col.type$size $nullString,$eol" )
  #end
  #if( $table.primaryKey )
  #set($cols = '')
  #foreach($col in $table.primaryKey.columns)
  #if( $col.size > 255 )
  #set ( $csize = "(255)" )
  #else
  #set ( $csize = '' )
  #end
  #set($cols = "$cols $col.name$csize,")
  #end
  #set( $dec = "$dec    PRIMARY KEY ($strings.chop($cols,1) ),$eol" )
  #end
  #foreach($fk in $table.foreignKeys)
  #set($dec = "$dec    FOREIGN KEY ($fk.localKey) REFERENCES $fk.foreignTable ($fk.foreignKey),$eol" )
  #end
  #foreach($index in $table.indices)
  #set($cols = '')
  #foreach($col in $index.columns)
  #if( $col.size > 255 )
  #set ( $csize = "(255)" )
  #else
  #set ( $csize = '' )
  #end
  #set($cols = "$cols $col.name$csize,")
  #end
  #set( $dec = "$dec    UNIQUE ($strings.chop($cols,1) ),$eol" )
  #end
  #set( $dec = $strings.chop($dec,1) )
  $dec
  ) TYPE=InnoDB;
  
  #end
  
  
  
  1.1                  jakarta-slide/src/conf/ojb/templates/mysql41.properties
  
  Index: mysql41.properties
  ===================================================================
  # JDBC to MySQL mappings.
  #
  # A good MySQL resource for determining these mappings is at
  # http://www.mysql.com/doc/C/o/Column_types.html
  
  BIT = BIT
  TINYINT = TINYINT
  SMALLINT = SMALLINT
  INTEGER = INTEGER
  BIGINT = BIGINT
  FLOAT = FLOAT
  REAL = REAL
  DOUBLE = DOUBLE
  NUMERIC = DECIMAL
  DECIMAL = DECIMAL
  CHAR = CHAR
  VARCHAR = VARCHAR
  LONGVARCHAR = MEDIUMTEXT
  DATE = DATETIME
  TIME = TIME
  TIMESTAMP = TIMESTAMP
  BINARY = BLOB
  VARBINARY = MEDIUMBLOB
  LONGVARBINARY = LONGBLOB
  NULL = NULL
  OTHER =
  JAVA_OBJECT =
  DISTINCT =
  STRUCT =
  ARRAY =
  BLOB = LONGBLOB
  CLOB = LONGTEXT
  REF =
  
  NOTNULL = NOT NULL
  
  
  
  1.1                  jakarta-slide/src/conf/ojb/templates/mysql41.vm
  
  Index: mysql41.vm
  ===================================================================
  # ----------------------------------------------------
  #foreach($table in $droptables)
  DROP TABLE IF EXISTS $table.name;
  #end
  
  # ----------------------------------------------------
  #foreach($table in $tables)
  CREATE TABLE $table.name (
  #set( $dec = '' )
  #foreach($col in $table.columns)
  #notnull($nullString $col)
  #if( $col.type=="VARCHAR" || $col.type=="TEXT" )
  #set( $charset="CHARACTER SET utf8 COLLATE utf8_general_ci" )
  #else
  #set( $charset='' )
  #end
  #if( $col.type=="TEXT" || $col.type=="MEDIUMTEXT" || $col.type=="LONGTEXT" )
  #set($size='')
  #else
  #set($size="$col.printSize()")
  #end
  #set( $dec = "$dec    $col.name  $col.type$size $charset $nullString,$eol" )
  #end
  #if( $table.primaryKey )
  #set($cols = '')
  #foreach($col in $table.primaryKey.columns)
  #if( $col.size > 255 )
  #set ( $csize = "(255)" )
  #else
  #set ( $csize = '' )
  #end
  #set($cols = "$cols $col.name$csize,")
  #end
  #set( $dec = "$dec    PRIMARY KEY ($strings.chop($cols,1) ),$eol" )
  #end
  #foreach($fk in $table.foreignKeys)
  #set($dec = "$dec    FOREIGN KEY ($fk.localKey) REFERENCES $fk.foreignTable ($fk.foreignKey),$eol" )
  #end
  #foreach($index in $table.indices)
  #set($cols = '')
  #foreach($col in $index.columns)
  #if( $col.size > 255 )
  #set ( $csize = "(255)" )
  #else
  #set ( $csize = '' )
  #end
  #set($cols = "$cols $col.name$csize,")
  #end
  #set( $dec = "$dec    KEY ${index.name} ($strings.chop($cols,1) ),$eol" )
  #end
  #set( $dec = $strings.chop($dec,1) )
  $dec
  ) TYPE=InnoDB CHARACTER SET utf8;
  
  #end
  
  
  
  1.1                  jakarta-slide/src/conf/ojb/templates/oracle.properties
  
  Index: oracle.properties
  ===================================================================
  # JDBC to Oracle mappings.
  #
  # Good Oracle resources for determining these mappings include:
  # http://technet.oracle.com/doc/oracle8i_816/java.816/a81354/basic3.htm
  # http://technet.oracle.com/docs/tech/migration/workbench/doc_library/MSAccess/ch3.htm
  
  BIT = NUMBER(1,0)
  TINYINT = NUMBER(3,0)
  SMALLINT = NUMBER(5,0)
  INTEGER = NUMBER
  BIGINT = NUMBER(20,0)
  FLOAT = FLOAT
  REAL = NUMBER
  DOUBLE = FLOAT
  NUMERIC = NUMBER
  DECIMAL = NUMBER
  CHAR = CHAR
  VARCHAR = VARCHAR2
  LONGVARCHAR = VARCHAR2
  DATE = DATE
  TIME = DATE
  TIMESTAMP = DATE
  BINARY = LONG RAW
  VARBINARY = BLOB
  LONGVARBINARY = LONG RAW
  NULL =
  OTHER =
  JAVA_OBJECT =
  DISTINCT =
  STRUCT =
  ARRAY =
  BLOB = BLOB
  CLOB = CLOB
  REF =
  
  NOTNULL = NOT NULL
  
  
  
  1.1                  jakarta-slide/src/conf/ojb/templates/oracle.vm
  
  Index: oracle.vm
  ===================================================================
  // ----------------------------------------------------
  #foreach($table in $droptables)
  DROP TABLE $table.name CASCADE CONSTRAINTS;
  #end
  
  // ----------------------------------------------------
  #foreach($table in $tables)
  CREATE TABLE $table.name (
  #set( $dec = '' )
  #foreach($col in $table.columns)
  #notnull($nullString $col)
  #if($col.type=="BLOB")
  #set($blob=$col.name)
  #else
  #set($blob='')
  #end
  #set( $dec = "$dec    $col.name  $col.type$col.printSize() $nullString,$eol" )
  #end
  #if( $table.primaryKey )
  #printcols($cols $table.primaryKey.columns)
  #set( $dec = "$dec    PRIMARY KEY ($cols ),$eol" )
  #end
  #foreach($fk in $table.foreignKeys)
  #set($dec = "$dec    FOREIGN KEY ($fk.localKey) REFERENCES $fk.foreignTable ($fk.foreignKey),$eol" )
  #end
  #foreach($index in $table.indices)
  #if($index.unique)
  #printcols($cols $index.columns)
  #set( $dec = "$dec    UNIQUE ($cols ),$eol" )
  #end
  #end
  #set( $dec = $strings.chop($dec,1) )
  $dec
  ) CACHE NOLOGGING#if($blob!='')$eol  LOB ($blob) STORE AS (NOCACHE NOLOGGING STORAGE(MAXEXTENTS UNLIMITED))#end;
  
  #end
  
  
  
  1.1                  jakarta-slide/src/conf/ojb/templates/postgresql.properties
  
  Index: postgresql.properties
  ===================================================================
  # JDBC to PostgreSQL mappings.
  #
  # See http://www.postgresql.org/idocs/index.php?datatype.html for more
  # information on PostgreSQL data types.
  
  BIT = BOOLEAN
  TINYINT = INT2
  SMALLINT = INT2
  INTEGER = INTEGER
  BIGINT = INT8
  FLOAT = FLOAT
  REAL = FLOAT
  BOOLEANCHAR = CHAR
  BOOLEANINT = INT2
  
  DOUBLE = DOUBLE PRECISION
  # numeric(precision, scale) / decimal(precision, scale)
  NUMERIC = NUMERIC
  DECIMAL = DECIMAL
  CHAR = CHAR
  # just use TEXT for everything
  VARCHAR = TEXT
  LONGVARCHAR = TEXT
  DATE = DATE
  TIME = TIME
  TIMESTAMP = TIMESTAMP
  BINARY = BYTEA
  VARBINARY = BYTEA
  LONGVARBINARY = BYTEA
  NULL =
  OTHER =
  JAVA_OBJECT =
  DISTINCT =
  STRUCT =
  ARRAY =
  BLOB = OID
  CLOB = TEXT
  REF =
  
  AUTOINCREMENT = SERIAL
  NOTNULL = NOT NULL
  
  
  
  1.1                  jakarta-slide/src/conf/ojb/templates/postgresql.vm
  
  Index: postgresql.vm
  ===================================================================
  ----------------------------------------------------
  #foreach($table in $droptables)
  DROP TABLE $table.name;
  #end
  
  ----------------------------------------------------
  #foreach($table in $tables)
  CREATE TABLE $table.name (
  #set( $dec = '' )
  #foreach($col in $table.columns)
  #notnull($nullString $col)
  #if($col.type == "TEXT" )
  #set($size = '')
  #else
  #set($size = "$col.printSize()")
  #end
  #set( $dec = "$dec    $col.name  $col.type$size $nullString,$eol" )
  #end
  #if( $table.primaryKey )
  #printcols($cols $table.primaryKey.columns)
  #set( $dec = "$dec    PRIMARY KEY ($cols ),$eol" )
  #end
  #foreach($fk in $table.foreignKeys)
  #set($dec = "$dec    CONSTRAINT ${table.name}_FK${velocityCount} FOREIGN KEY ($fk.localKey) REFERENCES $fk.foreignTable ($fk.foreignKey),$eol" )
  #end
  #foreach($index in $table.indices)
  #if($index.unique)
  #printcols($cols $index.columns)
  #set( $dec = "$dec    UNIQUE ($cols ),$eol" )
  #end
  #end
  #set( $dec = $strings.chop($dec,1) )
  $dec
  );
  
  #end
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org