List of usage examples for org.hibernate.mapping Column setSqlType
public void setSqlType(String sqlType)
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());/*from ww w .j ava2s. c o m*/ 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:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
protected void bindColumnConfigToColumn(Column column, ColumnConfig columnConfig) { if (columnConfig == null) { return;/*from w w w.ja v a 2s. c o m*/ } if (columnConfig.getLength() != -1) { column.setLength(columnConfig.getLength()); } if (columnConfig.getPrecision() != -1) { column.setPrecision(columnConfig.getPrecision()); } if (columnConfig.getScale() != -1) { column.setScale(columnConfig.getScale()); } if (columnConfig.getSqlType() != null && !columnConfig.getSqlType().isEmpty()) { column.setSqlType(columnConfig.getSqlType()); } column.setUnique(columnConfig.getUnique()); }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
protected void linkValueUsingAColumnCopy(GrailsDomainClassProperty prop, Column column, DependantValue key) { Column mappingColumn = new Column(); mappingColumn.setName(column.getName()); mappingColumn.setLength(column.getLength()); mappingColumn.setNullable(prop.isOptional()); mappingColumn.setSqlType(column.getSqlType()); mappingColumn.setValue(key);//from w w w. ja v a2s . c o m key.addColumn(mappingColumn); key.getTable().addColumn(mappingColumn); }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
protected void bindSimpleValue(GrailsDomainClassProperty grailsProp, GrailsDomainClassProperty parentProperty, SimpleValue simpleValue, String path, PropertyConfig propertyConfig, String sessionFactoryBeanName) { setTypeForPropertyConfig(grailsProp, simpleValue, propertyConfig); if (grailsProp.isDerived()) { Formula formula = new Formula(); formula.setFormula(propertyConfig.getFormula()); simpleValue.addFormula(formula); } else {/*from ww w . ja va2 s .c o m*/ Table table = simpleValue.getTable(); // Add the column definitions for this value/property. Note that // not all custom mapped properties will have column definitions, // in which case we still need to create a Hibernate column for // this value. List<?> columnDefinitions = propertyConfig != null ? propertyConfig.getColumns() : Arrays.asList(new Object[] { null }); if (columnDefinitions.isEmpty()) { columnDefinitions = Arrays.asList(new Object[] { null }); } for (int i = 0, n = columnDefinitions.size(); i < n; i++) { ColumnConfig cc = (ColumnConfig) columnDefinitions.get(i); Column column = new Column(); // Check for explicitly mapped column name and SQL type. if (cc != null) { if (cc.getName() != null) { column.setName(cc.getName()); } if (cc.getSqlType() != null) { column.setSqlType(cc.getSqlType()); } } column.setValue(simpleValue); if (cc != null) { if (cc.getLength() != -1) { column.setLength(cc.getLength()); } if (cc.getPrecision() != -1) { column.setPrecision(cc.getPrecision()); } if (cc.getScale() != -1) { column.setScale(cc.getScale()); } column.setUnique(cc.isUnique()); } bindColumn(grailsProp, parentProperty, column, cc, path, table, sessionFactoryBeanName); if (table != null) { table.addColumn(column); } simpleValue.addColumn(column); } } }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
private static void bindColumnConfigToColumn(Column column, ColumnConfig columnConfig) { if (columnConfig != null) { column.setLength(columnConfig.getLength()); column.setPrecision(columnConfig.getPrecision()); column.setSqlType(columnConfig.getSqlType()); column.setUnique(columnConfig.getUnique()); column.setScale(columnConfig.getScale()); }/*from ww w . ja va 2 s .c o m*/ }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
private static void linkValueUsingAColumnCopy(GrailsDomainClassProperty prop, Column column, DependantValue key) {// w w w . ja va2 s .c o m Column mappingColumn = new Column(); mappingColumn.setName(column.getName()); mappingColumn.setLength(column.getLength()); mappingColumn.setNullable(prop.isOptional()); mappingColumn.setSqlType(column.getSqlType()); mappingColumn.setValue(key); key.addColumn(mappingColumn); key.getTable().addColumn(mappingColumn); }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
private static void bindSimpleValue(GrailsDomainClassProperty grailsProp, GrailsDomainClassProperty parentProperty, SimpleValue simpleValue, String path, PropertyConfig propertyConfig, String sessionFactoryBeanName) { setTypeForPropertyConfig(grailsProp, simpleValue, propertyConfig); if (grailsProp.isDerived()) { Formula formula = new Formula(); formula.setFormula(propertyConfig.getFormula()); simpleValue.addFormula(formula); } else {//www . j a va 2 s.c o m Table table = simpleValue.getTable(); // Add the column definitions for this value/property. Note that // not all custom mapped properties will have column definitions, // in which case we still need to create a Hibernate column for // this value. List<?> columnDefinitions = propertyConfig != null ? propertyConfig.getColumns() : Arrays.asList(new Object[] { null }); if (columnDefinitions.isEmpty()) { columnDefinitions = Arrays.asList(new Object[] { null }); } for (int i = 0, n = columnDefinitions.size(); i < n; i++) { ColumnConfig cc = (ColumnConfig) columnDefinitions.get(i); Column column = new Column(); // Check for explicitly mapped column name and SQL type. if (cc != null) { if (cc.getName() != null) { column.setName(cc.getName()); } if (cc.getSqlType() != null) { column.setSqlType(cc.getSqlType()); } } column.setValue(simpleValue); bindColumn(grailsProp, parentProperty, column, cc, path, table, sessionFactoryBeanName); if (cc != null) { if (cc.getLength() != -1) { column.setLength(cc.getLength()); } if (cc.getPrecision() != -1) { column.setPrecision(cc.getPrecision()); } if (cc.getScale() != -1) { column.setScale(cc.getScale()); } column.setUnique(cc.isUnique()); } if (table != null) table.addColumn(column); simpleValue.addColumn(column); } } }
From source file:org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
protected void bindColumnConfigToColumn(PersistentProperty property, Column column, ColumnConfig columnConfig) { final PropertyConfig mappedForm = property != null ? (PropertyConfig) property.getMapping().getMappedForm() : null;//from w w w . j av a 2 s . com boolean allowUnique = mappedForm != null && !mappedForm.isUniqueWithinGroup(); if (columnConfig == null) { return; } if (columnConfig.getLength() != -1) { column.setLength(columnConfig.getLength()); } if (columnConfig.getPrecision() != -1) { column.setPrecision(columnConfig.getPrecision()); } if (columnConfig.getScale() != -1) { column.setScale(columnConfig.getScale()); } if (columnConfig.getSqlType() != null && !columnConfig.getSqlType().isEmpty()) { column.setSqlType(columnConfig.getSqlType()); } if (allowUnique) { column.setUnique(columnConfig.getUnique()); } }
From source file:org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
protected void linkValueUsingAColumnCopy(PersistentProperty prop, Column column, DependantValue key) { Column mappingColumn = new Column(); mappingColumn.setName(column.getName()); mappingColumn.setLength(column.getLength()); mappingColumn.setNullable(prop.isNullable()); mappingColumn.setSqlType(column.getSqlType()); mappingColumn.setValue(key);/* w w w.j a va2 s.com*/ key.addColumn(mappingColumn); key.getTable().addColumn(mappingColumn); }
From source file:org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
protected void bindSimpleValue(PersistentProperty grailsProp, PersistentProperty parentProperty, SimpleValue simpleValue, String path, PropertyConfig propertyConfig, String sessionFactoryBeanName) { setTypeForPropertyConfig(grailsProp, simpleValue, propertyConfig); final PropertyConfig mappedForm = (PropertyConfig) grailsProp.getMapping().getMappedForm(); if (mappedForm.isDerived()) { Formula formula = new Formula(); formula.setFormula(propertyConfig.getFormula()); simpleValue.addFormula(formula); } else {// w ww .j av a 2s .c o m Table table = simpleValue.getTable(); // Add the column definitions for this value/property. Note that // not all custom mapped properties will have column definitions, // in which case we still need to create a Hibernate column for // this value. List<?> columnDefinitions = propertyConfig != null ? propertyConfig.getColumns() : Arrays.asList(new Object[] { null }); if (columnDefinitions.isEmpty()) { columnDefinitions = Arrays.asList(new Object[] { null }); } for (Object columnDefinition : columnDefinitions) { ColumnConfig cc = (ColumnConfig) columnDefinition; Column column = new Column(); // Check for explicitly mapped column name and SQL type. if (cc != null) { if (cc.getName() != null) { column.setName(cc.getName()); } if (cc.getSqlType() != null) { column.setSqlType(cc.getSqlType()); } } column.setValue(simpleValue); if (cc != null) { if (cc.getLength() != -1) { column.setLength(cc.getLength()); } if (cc.getPrecision() != -1) { column.setPrecision(cc.getPrecision()); } if (cc.getScale() != -1) { column.setScale(cc.getScale()); } if (!mappedForm.isUniqueWithinGroup()) { column.setUnique(cc.isUnique()); } } bindColumn(grailsProp, parentProperty, column, cc, path, table, sessionFactoryBeanName); if (table != null) { table.addColumn(column); } simpleValue.addColumn(column); } } }