1 package org.hibernate.dialect; 4 5 import java.sql.Types ; 6 7 import org.hibernate.cfg.Environment; 8 import org.hibernate.sql.CaseFragment; 9 import org.hibernate.sql.DecodeCaseFragment; 10 import org.hibernate.sql.OracleJoinFragment; 11 import org.hibernate.sql.JoinFragment; 12 import org.hibernate.util.StringHelper; 13 14 18 public class SAPDBDialect extends Dialect { 19 20 public SAPDBDialect() { 21 super(); 22 registerColumnType( Types.BIT, "boolean" ); 23 registerColumnType( Types.BIGINT, "fixed(19,0)" ); 24 registerColumnType( Types.SMALLINT, "smallint" ); 25 registerColumnType( Types.TINYINT, "fixed(3,0)" ); 26 registerColumnType( Types.INTEGER, "int" ); 27 registerColumnType( Types.CHAR, "char(1)" ); 28 registerColumnType( Types.VARCHAR, "varchar($l)" ); 29 registerColumnType( Types.FLOAT, "float" ); 30 registerColumnType( Types.DOUBLE, "double precision" ); 31 registerColumnType( Types.DATE, "date" ); 32 registerColumnType( Types.TIME, "time" ); 33 registerColumnType( Types.TIMESTAMP, "timestamp" ); 34 registerColumnType( Types.VARBINARY, "long byte" ); 35 registerColumnType( Types.NUMERIC, "fixed($p,$s)" ); 36 registerColumnType( Types.CLOB, "long varchar" ); 37 registerColumnType( Types.BLOB, "long byte" ); 38 39 getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE); 40 41 } 42 43 public boolean dropConstraints() { 44 return false; 45 } 46 47 public String getAddColumnString() { 48 return "add"; 49 } 50 51 public String getAddForeignKeyConstraintString( 52 String constraintName, 53 String [] foreignKey, 54 String referencedTable, 55 String [] primaryKey, boolean referencesPrimaryKey 56 ) { 57 StringBuffer res = new StringBuffer (30) 58 .append(" foreign key ") 59 .append(constraintName) 60 .append(" (") 61 .append( StringHelper.join(", ", foreignKey) ) 62 .append(") references ") 63 .append(referencedTable); 64 65 if(!referencesPrimaryKey) { 66 res.append(" (") 67 .append( StringHelper.join(", ", primaryKey) ) 68 .append(')'); 69 } 70 71 return res.toString(); 72 } 73 74 public String getAddPrimaryKeyConstraintString(String constraintName) { 75 return " primary key "; 76 } 77 78 public String getNullColumnString() { 79 return " null"; 80 } 81 82 public String getSequenceNextValString(String sequenceName) { 83 return "select " + getSelectSequenceNextValString( sequenceName ) + " from dual"; 84 } 85 86 public String getSelectSequenceNextValString(String sequenceName) { 87 return sequenceName + ".nextval"; 88 } 89 90 public String getCreateSequenceString(String sequenceName) { 91 return "create sequence " + sequenceName; 92 } 93 94 public String getDropSequenceString(String sequenceName) { 95 return "drop sequence " + sequenceName; 96 } 97 98 public String getQuerySequencesString() { 99 return "select sequence_name from domain.sequences"; 100 } 101 102 public JoinFragment createOuterJoinFragment() { 103 return new OracleJoinFragment(); 104 } 105 106 107 public boolean supportsSequences() { 108 return true; 109 } 110 111 public CaseFragment createCaseFragment() { 112 return new DecodeCaseFragment(); 113 } 114 115 } 116 | Popular Tags |