List of usage examples for org.hibernate.dialect Dialect closeQuote
public char closeQuote()
From source file:org.nuxeo.ecm.directory.sql.repository.Column.java
License:Open Source License
public String getQuotedName(Dialect dialect) { return dialect.openQuote() + name + dialect.closeQuote(); }
From source file:org.nuxeo.ecm.directory.sql.repository.Table.java
License:Open Source License
/** * Computes the SQL statement to create the table. * * @param dialect the dialect./*from w ww . j a v a 2 s . c o m*/ * @return the SQL create string. */ public String getCreateSql(Dialect dialect) { StringBuilder buf = new StringBuilder(); char openQuote = dialect.openQuote(); char closeQuote = dialect.closeQuote(); buf.append("create table"); buf.append(' '); buf.append(openQuote); buf.append(name); buf.append(closeQuote); buf.append(" ("); boolean first = true; for (Column column : columns) { if (first) { first = false; } else { buf.append(", "); } buf.append(openQuote); buf.append(column.getName()); buf.append(closeQuote); buf.append(' '); if (column.isIdentity()) { if (dialect.hasDataTypeInIdentityColumn()) { buf.append(column.getSqlTypeString(dialect)); buf.append(' '); } buf.append(dialect.getIdentityColumnString(column.getSqlType())); } else { buf.append(column.getSqlTypeString(dialect)); String defaultValue = column.getDefaultValue(); if (defaultValue != null) { buf.append(" default "); buf.append(defaultValue); } if (column.isNullable()) { buf.append(dialect.getNullColumnString()); } else { buf.append(" not null"); } } // unique // check } // unique // check buf.append(')'); buf.append(dialect.getTableTypeString()); return buf.toString(); }
From source file:org.nuxeo.ecm.directory.sql.repository.Table.java
License:Open Source License
/** * Computes the SQL statement to drop the table. * * @param dialect the dialect./*from www .j a va 2 s . c o m*/ * @return the SQL drop string. */ public String getDropSql(Dialect dialect) { StringBuilder buf = new StringBuilder(); buf.append("drop table "); if (dialect.supportsIfExistsBeforeTableName()) { buf.append("if exists "); } buf.append(dialect.openQuote()); buf.append(name); buf.append(dialect.closeQuote()); buf.append(dialect.getCascadeConstraintsString()); if (dialect.supportsIfExistsAfterTableName()) { buf.append(" if exists"); } return buf.toString(); }