List of usage examples for org.hibernate.mapping Value getType
public Type getType() throws MappingException;
From source file:com.wavemaker.runtime.data.hibernate.DataServiceMetaData_Hib.java
License:Open Source License
private void initProperty(String owningClassName, Property p, Map<String, Property> propertiesMap) { this.allProperties.put(owningClassName, p); if (p != null) { this.allPropertyNames.put(owningClassName, p.getName()); propertiesMap.put(p.getName(), p); Value v = p.getValue(); if (v.getType().isEntityType() || !v.isSimpleValue()) { this.relProperties.put(owningClassName, p); this.relPropertyNames.put(owningClassName, p.getName()); }//w w w . j av a 2 s . com if (p.getType().isComponentType()) { addComponentProperties(p); } } }
From source file:org.ow2.bonita.util.DbTool.java
License:Open Source License
@SuppressWarnings("unchecked") public static void updateDatabaseSchema(Configuration configuration) { if (isOnDb("mysql", configuration)) { LOG.severe("Running on MySQL database, updating schema..."); final PersistentClass pc = configuration.getClassMapping(Lob.class.getName()); final Table table = pc.getTable(); final Iterator<Column> columns = (Iterator<Column>) table.getColumnIterator(); while (columns.hasNext()) { final Column column = columns.next(); final String columnName = "BLOB_VALUE_"; if (column.getName().equals(columnName)) { LOG.severe("Updating " + columnName + " column..."); column.setSqlType("LONGBLOB"); column.setLength(518576); }//w w w .ja va 2 s .co m } } else if (DbTool.isOnDb("oracle", configuration)) { LOG.severe("Running on Oracle database, updating schema..."); final Iterator<Table> tables = (Iterator<Table>) configuration.getTableMappings(); while (tables.hasNext()) { final Table table = tables.next(); final Iterator<Column> columns = (Iterator<Column>) table.getColumnIterator(); while (columns.hasNext()) { final Column column = columns.next(); final Value value = column.getValue(); // Prevent ORA-01754: a table may contain only one column of type LONG if (value.getType() instanceof TextType) { column.setSqlType("CLOB"); } } } } /*else if (isOnDb("sybase", config)) { LOG.severe("Running on Sybase DB, updating schema..."); //iterate over all tables and all columns to replace type=text final Iterator<Table> tables = (Iterator<Table>) config.getTableMappings(); while (tables.hasNext()) { final Table table = tables.next(); final Iterator<Column> columns = table.getColumnIterator(); while (columns.hasNext()) { final Column column = columns.next(); System.err.println("Column.name=" + column.getName() + ", column=" + column.getDefaultValue()); if (!column.getName().equals("BLOB_VALUE_") && column.getSqlType() != null && column.getSqlType().equals("CLOB")) { LOG.severe("Updating " + column.getName() + " column..."); column.setSqlType("LONGVARCHAR"); } } } } */ }