List of usage examples for org.hibernate.mapping Column setSqlTypeCode
public void setSqlTypeCode(Integer typeCode)
From source file:com.manydesigns.portofino.persistence.hibernate.HibernateConfig.java
License:Open Source License
protected Column createColumn(Mappings mappings, Table tab, com.manydesigns.portofino.model.database.Column column) { Column col = new Column(); col.setName(escapeName(column.getColumnName())); col.setLength(column.getLength());// ww w . jav a 2 s. c om col.setPrecision(column.getLength()); col.setScale(column.getScale()); col.setNullable(column.isNullable()); String columnType = column.getColumnType(); int jdbcType = column.getJdbcType(); col.setSqlTypeCode(jdbcType); col.setSqlType(columnType); SimpleValue value = new SimpleValue(mappings, tab); if (!setHibernateType(value, column, column.getActualJavaType(), jdbcType)) { logger.error("Skipping column {}", column.getQualifiedName()); return null; } value.addColumn(col); tab.addColumn(col); mappings.addColumnBinding(column.getColumnName(), col, tab); return col; }
From source file:com.zutubi.pulse.master.transfer.jdbc.HibernateTransferSource.java
License:Apache License
public void transferTo(TransferTarget target) throws TransferException { try {//from w ww.j a v a2s .c o m // ensure that the mappings are built. configuration.buildMappings(); Mapping mapping = new HibernateMapping(configuration); target.start(); Connection con = null; try { con = dataSource.getConnection(); Iterator tables = configuration.getTableMappings(); while (tables.hasNext()) { Table table = (Table) tables.next(); List<Column> columns = MappingUtils.getColumns(table); for (Column column : columns) { if (column.getSqlTypeCode() == null) { column.setSqlTypeCode(column.getSqlTypeCode(mapping)); } } exportTable(target, table, con, columns); } // handle the special case. Table table = HibernateUniqueKeyTable.getMapping(); exportTable(target, table, con, MappingUtils.getColumns(table)); } finally { JDBCUtils.close(con); } target.end(); } catch (SQLException e) { throw new HibernateTransferException(e); } }
From source file:com.zutubi.pulse.master.transfer.jdbc.HibernateUniqueKeyTable.java
License:Apache License
public static Table getMapping() { Table table = new Table("hibernate_unique_key"); Column column = new Column("next_hi"); SimpleValue value = new SimpleValue(null, table); value.setTypeName(int.class.getName()); column.setValue(value);/*from w w w. j a va2 s.c o m*/ column.setSqlTypeCode(Types.INTEGER); table.addColumn(column); return table; }
From source file:net.lshift.hibernate.migrations.AlterTableBuilder.java
License:Apache License
private static Column buildColumnDefinition(String name, int sqlType, int length, boolean nullable, Object defaultVal) {//from www .ja va 2 s. c o m Column col = new Column(name); col.setSqlTypeCode(sqlType); col.setNullable(nullable); col.setLength(length); col.setDefaultValue(defaultVal != null ? defaultVal.toString() : null); return col; }
From source file:net.lshift.hibernate.migrations.CreateTableBuilder.java
License:Apache License
public CreateTableBuilder column(String name, int sqlType, int length, boolean nullable, Object defaultVal) { Column col = new Column(name); col.setNullable(nullable);//from w w w . j av a 2 s . co m col.setSqlTypeCode(sqlType); col.setLength(length); col.setDefaultValue(defaultVal != null ? defaultVal.toString() : null); columns.add(col); return this; }
From source file:org.teiid.spring.autoconfigure.RedirectionSchemaInitializer.java
License:Apache License
List<Resource> generatedScripts() { List<Resource> resources = Collections.emptyList(); for (PersistentClass clazz : metadata.getEntityBindings()) { org.hibernate.mapping.Table ormTable = clazz.getTable(); String tableName = ormTable.getQuotedName(); if (this.schema.getTable(tableName) != null) { org.hibernate.mapping.Column c = new org.hibernate.mapping.Column( RedirectionSchemaBuilder.ROW_STATUS_COLUMN); c.setSqlTypeCode(TypeFacility.getSQLTypeFromRuntimeType(Integer.class)); c.setSqlType(JDBCSQLTypeInfo.getTypeName(TypeFacility.getSQLTypeFromRuntimeType(Integer.class))); ormTable.addColumn(c);//from w ww . j a va 2 s. c om ormTable.setName(tableName + TeiidConstants.REDIRECTED_TABLE_POSTFIX); } } List<String> statements = createScript(metadata, dialect, true); StringBuilder sb = new StringBuilder(); for (String s : statements) { // we have no need for sequences in the redirected scenario, they are fed from // other side. if (s.startsWith("drop sequence") || s.startsWith("create sequence")) { continue; } sb.append(s).append(";\n"); } logger.debug("Redirected Schema:\n" + sb.toString()); resources = Arrays.asList(new ByteArrayResource(sb.toString().getBytes())); return resources; }