org.hibernate.tool.hbm2ddl.ColumnMetadata Java Examples
The following examples show how to use
org.hibernate.tool.hbm2ddl.ColumnMetadata.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Table.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) { Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column col = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() ); if ( columnInfo == null ) { throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName())); } else { final boolean typesMatch = col.getSqlType( dialect, mapping ) .startsWith( columnInfo.getTypeName().toLowerCase() ) || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping ); if ( !typesMatch ) { throw new HibernateException( "Wrong column type: " + col.getName() + ", expected: " + col.getSqlType( dialect, mapping ) ); } } } }
Example #2
Source File: Table.java From lams with GNU General Public License v2.0 | 5 votes |
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) { Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column col = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() ); if ( columnInfo == null ) { throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName())); } else { final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase(Locale.ROOT) .startsWith( columnInfo.getTypeName().toLowerCase(Locale.ROOT) ) || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping ); if ( !typesMatch ) { throw new HibernateException( "Wrong column type in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) + " for column " + col.getName() + ". Found: " + columnInfo.getTypeName().toLowerCase(Locale.ROOT) + ", expected: " + col.getSqlType( dialect, mapping ) ); } } } }
Example #3
Source File: Table.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) { Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column col = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() ); if ( columnInfo == null ) { throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName())); } else { final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase() .startsWith( columnInfo.getTypeName().toLowerCase() ) || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping ); if ( !typesMatch ) { throw new HibernateException( "Wrong column type in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) + " for column " + col.getName() + ". Found: " + columnInfo.getTypeName().toLowerCase() + ", expected: " + col.getSqlType( dialect, mapping ) ); } } } }
Example #4
Source File: Table.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) { Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column col = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() ); if ( columnInfo == null ) { throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName())); } else { final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase() .startsWith( columnInfo.getTypeName().toLowerCase() ) || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping ); if ( !typesMatch ) { throw new HibernateException( "Wrong column type in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) + " for column " + col.getName() + ". Found: " + columnInfo.getTypeName().toLowerCase() + ", expected: " + col.getSqlType( dialect, mapping ) ); } } } }
Example #5
Source File: Table.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) { Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column col = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() ); if ( columnInfo == null ) { throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName())); } else { final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase() .startsWith( columnInfo.getTypeName().toLowerCase() ) || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping ); if ( !typesMatch ) { throw new HibernateException( "Wrong column type in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) + " for column " + col.getName() + ". Found: " + columnInfo.getTypeName().toLowerCase() + ", expected: " + col.getSqlType( dialect, mapping ) ); } } } }
Example #6
Source File: Table.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) { Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column col = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() ); if ( columnInfo == null ) { throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName())); } else { final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase() .startsWith( columnInfo.getTypeName().toLowerCase() ) || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping ); if ( !typesMatch ) { throw new HibernateException( "Wrong column type in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) + " for column " + col.getName() + ". Found: " + columnInfo.getTypeName().toLowerCase() + ", expected: " + col.getSqlType( dialect, mapping ) ); } } } }
Example #7
Source File: Table.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) { Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column col = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() ); if ( columnInfo == null ) { throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName())); } else { final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase() .startsWith( columnInfo.getTypeName().toLowerCase() ) || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping ); if ( !typesMatch ) { throw new HibernateException( "Wrong column type in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) + " for column " + col.getName() + ". Found: " + columnInfo.getTypeName().toLowerCase() + ", expected: " + col.getSqlType( dialect, mapping ) ); } } } }
Example #8
Source File: Table.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
public Iterator sqlAlterStrings(Dialect dialect, Mapping p, TableMetadata tableInfo, String defaultCatalog, String defaultSchema) throws HibernateException { StringBuffer root = new StringBuffer( "alter table " ) .append( getQualifiedName( dialect, defaultCatalog, defaultSchema ) ) .append( ' ' ) .append( dialect.getAddColumnString() ); Iterator iter = getColumnIterator(); List results = new ArrayList(); while ( iter.hasNext() ) { Column column = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( column.getName() ); if ( columnInfo == null ) { // the column doesnt exist at all. StringBuffer alter = new StringBuffer( root.toString() ) .append( ' ' ) .append( column.getQuotedName( dialect ) ) .append( ' ' ) .append( column.getSqlType( dialect, p ) ); String defaultValue = column.getDefaultValue(); if ( defaultValue != null ) { alter.append( " default " ).append( defaultValue ); } if ( column.isNullable() ) { alter.append( dialect.getNullColumnString() ); } else { alter.append( " not null" ); } boolean useUniqueConstraint = column.isUnique() && dialect.supportsUnique() && ( !column.isNullable() || dialect.supportsNotNullUnique() ); if ( useUniqueConstraint ) { alter.append( " unique" ); } if ( column.hasCheckConstraint() && dialect.supportsColumnCheck() ) { alter.append( " check(" ) .append( column.getCheckConstraint() ) .append( ")" ); } String columnComment = column.getComment(); if ( columnComment != null ) { alter.append( dialect.getColumnComment( columnComment ) ); } results.add( alter.toString() ); } } return results.iterator(); }
Example #9
Source File: Table.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
public Iterator sqlAlterStrings(Dialect dialect, Mapping p, TableMetadata tableInfo, String defaultCatalog, String defaultSchema) throws HibernateException { StringBuffer root = new StringBuffer( "alter table " ) .append( getQualifiedName( dialect, defaultCatalog, defaultSchema ) ) .append( ' ' ) .append( dialect.getAddColumnString() ); Iterator iter = getColumnIterator(); List results = new ArrayList(); while ( iter.hasNext() ) { Column column = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( column.getName() ); if ( columnInfo == null ) { // the column doesnt exist at all. StringBuffer alter = new StringBuffer( root.toString() ) .append( ' ' ) .append( column.getQuotedName( dialect ) ) .append( ' ' ) .append( column.getSqlType( dialect, p ) ); String defaultValue = column.getDefaultValue(); if ( defaultValue != null ) { alter.append( " default " ).append( defaultValue ); } if ( column.isNullable() ) { alter.append( dialect.getNullColumnString() ); } else { alter.append( " not null" ); } boolean useUniqueConstraint = column.isUnique() && dialect.supportsUnique() && ( !column.isNullable() || dialect.supportsNotNullUnique() ); if ( useUniqueConstraint ) { alter.append( " unique" ); } if ( column.hasCheckConstraint() && dialect.supportsColumnCheck() ) { alter.append( " check(" ) .append( column.getCheckConstraint() ) .append( ")" ); } String columnComment = column.getComment(); if ( columnComment != null ) { alter.append( dialect.getColumnComment( columnComment ) ); } results.add( alter.toString() ); } } return results.iterator(); }
Example #10
Source File: Table.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
public Iterator sqlAlterStrings(Dialect dialect, Mapping p, TableMetadata tableInfo, String defaultCatalog, String defaultSchema) throws HibernateException { StringBuffer root = new StringBuffer( "alter table " ) .append( getQualifiedName( dialect, defaultCatalog, defaultSchema ) ) .append( ' ' ) .append( dialect.getAddColumnString() ); Iterator iter = getColumnIterator(); List results = new ArrayList(); while ( iter.hasNext() ) { Column column = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( column.getName() ); if ( columnInfo == null ) { // the column doesnt exist at all. StringBuffer alter = new StringBuffer( root.toString() ) .append( ' ' ) .append( column.getQuotedName( dialect ) ) .append( ' ' ) .append( column.getSqlType( dialect, p ) ); String defaultValue = column.getDefaultValue(); if ( defaultValue != null ) { alter.append( " default " ).append( defaultValue ); } if ( column.isNullable() ) { alter.append( dialect.getNullColumnString() ); } else { alter.append( " not null" ); } boolean useUniqueConstraint = column.isUnique() && dialect.supportsUnique() && ( !column.isNullable() || dialect.supportsNotNullUnique() ); if ( useUniqueConstraint ) { alter.append( " unique" ); } if ( column.hasCheckConstraint() && dialect.supportsColumnCheck() ) { alter.append( " check(" ) .append( column.getCheckConstraint() ) .append( ")" ); } String columnComment = column.getComment(); if ( columnComment != null ) { alter.append( dialect.getColumnComment( columnComment ) ); } results.add( alter.toString() ); } } return results.iterator(); }
Example #11
Source File: Table.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
public Iterator sqlAlterStrings(Dialect dialect, Mapping p, TableMetadata tableInfo, String defaultCatalog, String defaultSchema) throws HibernateException { StringBuffer root = new StringBuffer( "alter table " ) .append( getQualifiedName( dialect, defaultCatalog, defaultSchema ) ) .append( ' ' ) .append( dialect.getAddColumnString() ); Iterator iter = getColumnIterator(); List results = new ArrayList(); while ( iter.hasNext() ) { Column column = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( column.getName() ); if ( columnInfo == null ) { // the column doesnt exist at all. StringBuffer alter = new StringBuffer( root.toString() ) .append( ' ' ) .append( column.getQuotedName( dialect ) ) .append( ' ' ) .append( column.getSqlType( dialect, p ) ); String defaultValue = column.getDefaultValue(); if ( defaultValue != null ) { alter.append( " default " ).append( defaultValue ); } if ( column.isNullable() ) { alter.append( dialect.getNullColumnString() ); } else { alter.append( " not null" ); } boolean useUniqueConstraint = column.isUnique() && dialect.supportsUnique() && ( !column.isNullable() || dialect.supportsNotNullUnique() ); if ( useUniqueConstraint ) { alter.append( " unique" ); } if ( column.hasCheckConstraint() && dialect.supportsColumnCheck() ) { alter.append( " check(" ) .append( column.getCheckConstraint() ) .append( ")" ); } String columnComment = column.getComment(); if ( columnComment != null ) { alter.append( dialect.getColumnComment( columnComment ) ); } results.add( alter.toString() ); } } return results.iterator(); }
Example #12
Source File: Table.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
public Iterator sqlAlterStrings(Dialect dialect, Mapping p, TableMetadata tableInfo, String defaultCatalog, String defaultSchema) throws HibernateException { StringBuffer root = new StringBuffer( "alter table " ) .append( getQualifiedName( dialect, defaultCatalog, defaultSchema ) ) .append( ' ' ) .append( dialect.getAddColumnString() ); Iterator iter = getColumnIterator(); List results = new ArrayList(); while ( iter.hasNext() ) { Column column = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( column.getName() ); if ( columnInfo == null ) { // the column doesnt exist at all. StringBuffer alter = new StringBuffer( root.toString() ) .append( ' ' ) .append( column.getQuotedName( dialect ) ) .append( ' ' ) .append( column.getSqlType( dialect, p ) ); String defaultValue = column.getDefaultValue(); if ( defaultValue != null ) { alter.append( " default " ).append( defaultValue ); } if ( column.isNullable() ) { alter.append( dialect.getNullColumnString() ); } else { alter.append( " not null" ); } boolean useUniqueConstraint = column.isUnique() && dialect.supportsUnique() && ( !column.isNullable() || dialect.supportsNotNullUnique() ); if ( useUniqueConstraint ) { alter.append( " unique" ); } if ( column.hasCheckConstraint() && dialect.supportsColumnCheck() ) { alter.append( " check(" ) .append( column.getCheckConstraint() ) .append( ")" ); } String columnComment = column.getComment(); if ( columnComment != null ) { alter.append( dialect.getColumnComment( columnComment ) ); } results.add( alter.toString() ); } } return results.iterator(); }
Example #13
Source File: Table.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public Iterator sqlAlterStrings(Dialect dialect, Mapping p, TableMetadata tableInfo, String defaultCatalog, String defaultSchema) throws HibernateException { StringBuffer root = new StringBuffer( "alter table " ) .append( getQualifiedName( dialect, defaultCatalog, defaultSchema ) ) .append( ' ' ) .append( dialect.getAddColumnString() ); Iterator iter = getColumnIterator(); List results = new ArrayList(); while ( iter.hasNext() ) { Column column = (Column) iter.next(); ColumnMetadata columnInfo = tableInfo.getColumnMetadata( column.getName() ); if ( columnInfo == null ) { // the column doesnt exist at all. StringBuffer alter = new StringBuffer( root.toString() ) .append( ' ' ) .append( column.getQuotedName( dialect ) ) .append( ' ' ) .append( column.getSqlType( dialect, p ) ); String defaultValue = column.getDefaultValue(); if ( defaultValue != null ) { alter.append( " default " ).append( defaultValue ); if ( column.isNullable() ) { alter.append( dialect.getNullColumnString() ); } else { alter.append( " not null" ); } } boolean useUniqueConstraint = column.isUnique() && dialect.supportsUnique() && ( !column.isNullable() || dialect.supportsNotNullUnique() ); if ( useUniqueConstraint ) { alter.append( " unique" ); } if ( column.hasCheckConstraint() && dialect.supportsColumnCheck() ) { alter.append( " check(" ) .append( column.getCheckConstraint() ) .append( ")" ); } String columnComment = column.getComment(); if ( columnComment != null ) { alter.append( dialect.getColumnComment( columnComment ) ); } results.add( alter.toString() ); } } return results.iterator(); }