List of usage examples for org.hibernate.mapping Column getSqlType
public String getSqlType()
From source file:com.blazebit.persistence.integration.hibernate.base.HibernateJpaProvider.java
License:Apache License
private String[] getColumnTypesForColumnNames(EntityType<?> entityType, String[] columnNames, Table[] tables) { String[] columnTypes = new String[columnNames.length]; for (int i = 0; i < columnNames.length; i++) { Column column = null; for (int j = 0; j < tables.length; j++) { column = tables[j].getColumn(new Column(columnNames[i])); if (column != null) { break; }/*from ww w .j ava 2s.com*/ } if (column == null) { throw new IllegalArgumentException( "Could not find column '" + columnNames[i] + "' in entity: " + entityType.getName()); } columnTypes[i] = column.getSqlType(); } return columnTypes; }
From source file:com.clueride.rest.MemberWebService.java
License:Apache License
private void dumpEntities() { Metadata metadata = MetadataExtractorIntegrator.INSTANCE.getMetadata(); for (PersistentClass persistentClass : metadata.getEntityBindings()) { Table table = persistentClass.getTable(); LOGGER.info(String.format("Entity: {} is mapped to table: {}", persistentClass.getClassName(), table.getName()));/*from w w w . ja v a2s. com*/ for (Iterator propertyIterator = persistentClass.getPropertyIterator(); propertyIterator.hasNext();) { Property property = (Property) propertyIterator.next(); for (Iterator columnIterator = property.getColumnIterator(); columnIterator.hasNext();) { Column column = (Column) columnIterator.next(); LOGGER.info(String.format("Property: {} is mapped on table column: {} of type: {}", property.getName(), column.getName(), column.getSqlType())); } } } }
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);// w w w. java2 s . c om 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 linkValueUsingAColumnCopy(GrailsDomainClassProperty prop, Column column, DependantValue key) {// w ww.j av a 2 s. co 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.GrailsDomainBinderTests.java
License:Apache License
/** * Tests that single- and multi-column user type mappings work * correctly. Also Checks that the "sqlType" property is honoured. *///from w w w . j a v a 2 s. co m public void testUserTypeMappings() { DefaultGrailsDomainConfiguration config = getDomainConfig(MULTI_COLUMN_USER_TYPE_DEFINITION); PersistentClass persistentClass = config.getClassMapping("Item"); // First check the "name" property and its associated column. Property nameProperty = persistentClass.getProperty("name"); assertEquals(1, nameProperty.getColumnSpan()); assertEquals("name", nameProperty.getName()); Column column = (Column) nameProperty.getColumnIterator().next(); assertEquals("s_name", column.getName()); assertEquals("text", column.getSqlType()); // Next the "other" property. Property otherProperty = persistentClass.getProperty("other"); assertEquals(1, otherProperty.getColumnSpan()); assertEquals("other", otherProperty.getName()); column = (Column) otherProperty.getColumnIterator().next(); assertEquals("other", column.getName()); assertEquals("wrapper-characters", column.getSqlType()); assertEquals(MyUserType.class.getName(), column.getValue().getType().getName()); assertTrue(column.getValue() instanceof SimpleValue); SimpleValue v = (SimpleValue) column.getValue(); assertEquals("myParam1", v.getTypeParameters().get("param1")); assertEquals("myParam2", v.getTypeParameters().get("param2")); // And now for the "price" property, which should have two // columns. Property priceProperty = persistentClass.getProperty("price"); assertEquals(2, priceProperty.getColumnSpan()); assertEquals("price", priceProperty.getName()); Iterator colIter = priceProperty.getColumnIterator(); column = (Column) colIter.next(); assertEquals("value", column.getName()); assertNull("SQL type should have been 'null' for 'value' column.", column.getSqlType()); column = (Column) colIter.next(); assertEquals("currency_code", column.getName()); assertEquals("text", column.getSqlType()); }
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 ww.ja v a2 s .c o m*/ key.addColumn(mappingColumn); key.getTable().addColumn(mappingColumn); }