org.hibernate.mapping.Column Java Examples
The following examples show how to use
org.hibernate.mapping.Column.
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: MetadataTest.java From high-performance-java-persistence with Apache License 2.0 | 6 votes |
@Test public void testEntityToDatabaseBindingMetadata() { Metadata metadata = MetadataExtractorIntegrator.INSTANCE.getMetadata(); for ( PersistentClass persistentClass : metadata.getEntityBindings()) { Table table = persistentClass.getTable(); LOGGER.info( "Entity: {} is mapped to table: {}", persistentClass.getClassName(), table.getName() ); 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( "Property: {} is mapped on table column: {} of type: {}", property.getName(), column.getName(), column.getSqlType() ); } } } }
Example #2
Source File: IndexOrUniqueKeySecondPass.java From lams with GNU General Public License v2.0 | 6 votes |
private void addConstraintToColumn(final String columnName ) { Column column = table.getColumn( new Column( buildingContext.getMetadataCollector().getPhysicalColumnName( table, columnName ) ) ); if ( column == null ) { throw new AnnotationException( "@Index references a unknown column: " + columnName ); } if ( unique ) { table.getOrCreateUniqueKey( indexName ).addColumn( column ); } else { table.getOrCreateIndex( indexName ).addColumn( column ); } }
Example #3
Source File: SpannerTableStatements.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 6 votes |
private static List<Column> getSortedPkColumns(Table table, Metadata metadata) { Interleaved interleaved = SchemaUtils.getInterleaveAnnotation(table, metadata); if (interleaved == null) { return table.getPrimaryKey().getColumns(); } Table parentTable = SchemaUtils.getTable(interleaved.parentEntity(), metadata); List<Column> sortedParentPkColumns = getSortedPkColumns(parentTable, metadata); List<Column> sortedCurrentPkColumns = table.getPrimaryKey().getColumns().stream() .filter(column -> !sortedParentPkColumns.contains(column)) .collect(Collectors.toList()); ArrayList<Column> currentPkColumns = new ArrayList<>(); currentPkColumns.addAll(sortedParentPkColumns); currentPkColumns.addAll(sortedCurrentPkColumns); return currentPkColumns; }
Example #4
Source File: TypeSafeActivator.java From lams with GNU General Public License v2.0 | 6 votes |
private static void applyMin(Property property, ConstraintDescriptor<?> descriptor, Dialect dialect) { if ( Min.class.equals( descriptor.getAnnotation().annotationType() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Min> minConstraint = (ConstraintDescriptor<Min>) descriptor; long min = minConstraint.getAnnotation().value(); @SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator(); if ( itor.hasNext() ) { final Selectable selectable = itor.next(); if ( Column.class.isInstance( selectable ) ) { Column col = (Column) selectable; String checkConstraint = col.getQuotedName(dialect) + ">=" + min; applySQLCheck( col, checkConstraint ); } } } }
Example #5
Source File: SpannerTableStatements.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 6 votes |
/** * Generates the statements needed to create a table. */ public List<String> createTable(Table table, Metadata metadata) { if (spannerDatabaseInfo.getAllTables().contains(table.getName())) { return Collections.EMPTY_LIST; } Iterable<Column> keyColumns; if (table.hasPrimaryKey()) { // a typical table that corresponds to an entity type keyColumns = getSortedPkColumns(table, metadata); } else if (isElementCollection(table, metadata)) { // a table that is actually an element collection property keyColumns = table::getColumnIterator; } else { // the case corresponding to a sequence-table that will only have 1 row. keyColumns = Collections.emptyList(); } return getCreateTableStrings(table, metadata, keyColumns); }
Example #6
Source File: TypeSafeActivator.java From lams with GNU General Public License v2.0 | 6 votes |
private static void applyMax(Property property, ConstraintDescriptor<?> descriptor, Dialect dialect) { if ( Max.class.equals( descriptor.getAnnotation().annotationType() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Max> maxConstraint = (ConstraintDescriptor<Max>) descriptor; long max = maxConstraint.getAnnotation().value(); @SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator(); if ( itor.hasNext() ) { final Selectable selectable = itor.next(); if ( Column.class.isInstance( selectable ) ) { Column col = (Column) selectable; String checkConstraint = col.getQuotedName( dialect ) + "<=" + max; applySQLCheck( col, checkConstraint ); } } } }
Example #7
Source File: TypeSafeActivator.java From lams with GNU General Public License v2.0 | 6 votes |
private static void applyDigits(Property property, ConstraintDescriptor<?> descriptor) { if ( Digits.class.equals( descriptor.getAnnotation().annotationType() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Digits> digitsConstraint = (ConstraintDescriptor<Digits>) descriptor; int integerDigits = digitsConstraint.getAnnotation().integer(); int fractionalDigits = digitsConstraint.getAnnotation().fraction(); @SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator(); if ( itor.hasNext() ) { final Selectable selectable = itor.next(); if ( Column.class.isInstance( selectable ) ) { Column col = (Column) selectable; col.setPrecision( integerDigits + fractionalDigits ); col.setScale( fractionalDigits ); } } } }
Example #8
Source File: TypeSafeActivator.java From lams with GNU General Public License v2.0 | 6 votes |
private static void applySize(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( Size.class.equals( descriptor.getAnnotation().annotationType() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Size> sizeConstraint = (ConstraintDescriptor<Size>) descriptor; int max = sizeConstraint.getAnnotation().max(); @SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator(); if ( itor.hasNext() ) { final Selectable selectable = itor.next(); Column col = (Column) selectable; if ( max < Integer.MAX_VALUE ) { col.setLength( max ); } } } }
Example #9
Source File: TypeSafeActivator.java From lams with GNU General Public License v2.0 | 6 votes |
private static void applyLength(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( "org.hibernate.validator.constraints.Length".equals( descriptor.getAnnotation().annotationType().getName() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") int max = (Integer) descriptor.getAttributes().get( "max" ); @SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator(); if ( itor.hasNext() ) { final Selectable selectable = itor.next(); if ( Column.class.isInstance( selectable ) ) { Column col = (Column) selectable; if ( max < Integer.MAX_VALUE ) { col.setLength( max ); } } } } }
Example #10
Source File: Ejb3JoinColumn.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Called to apply column definitions from the referenced FK column to this column. * * @param column the referenced column. */ public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping.Column column) { if (getMappingColumn() != null) { // columnDefinition can also be specified using @JoinColumn, hence we have to check // whether it is set or not if ( StringHelper.isEmpty( sqlType ) ) { sqlType = column.getSqlType(); getMappingColumn().setSqlType( sqlType ); } // these properties can only be applied on the referenced column - we can just take them over getMappingColumn().setLength(column.getLength()); getMappingColumn().setPrecision(column.getPrecision()); getMappingColumn().setScale(column.getScale()); } }
Example #11
Source File: ForeignKeyMetadata.java From lams with GNU General Public License v2.0 | 6 votes |
public boolean matches(ForeignKey fk) { if ( refTable.equalsIgnoreCase( fk.getReferencedTable().getName() ) ) { if ( fk.getColumnSpan() == references.size() ) { List fkRefs; if ( fk.isReferenceToPrimaryKey() ) { fkRefs = fk.getReferencedTable().getPrimaryKey().getColumns(); } else { fkRefs = fk.getReferencedColumns(); } for ( int i = 0; i < fk.getColumnSpan(); i++ ) { Column column = fk.getColumn( i ); Column ref = ( Column ) fkRefs.get( i ); if ( !hasReference( column, ref ) ) { return false; } } return true; } } return false; }
Example #12
Source File: PropertyRefTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void testForeignKeyCreation() { PersistentClass classMapping = getCfg().getClassMapping("org.hibernate.test.propertyref.basic.Account"); Iterator foreignKeyIterator = classMapping.getTable().getForeignKeyIterator(); boolean found = false; while ( foreignKeyIterator.hasNext() ) { ForeignKey element = (ForeignKey) foreignKeyIterator.next(); if(element.getReferencedEntityName().equals(Person.class.getName() ) ) { if(!element.isReferenceToPrimaryKey() ) { List referencedColumns = element.getReferencedColumns(); Column column = (Column) referencedColumns.get(0); if(column.getName().equals("person_userid") ) { found = true; // extend test to include the columns } } } } assertTrue("Property ref foreign key not found",found); }
Example #13
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public static void bindColumn(Element node, Column column, boolean isNullable) { Attribute lengthNode = node.attribute( "length" ); if ( lengthNode != null ) column.setLength( Integer.parseInt( lengthNode.getValue() ) ); Attribute scalNode = node.attribute( "scale" ); if ( scalNode != null ) column.setScale( Integer.parseInt( scalNode.getValue() ) ); Attribute precNode = node.attribute( "precision" ); if ( precNode != null ) column.setPrecision( Integer.parseInt( precNode.getValue() ) ); Attribute nullNode = node.attribute( "not-null" ); column.setNullable( nullNode == null ? isNullable : nullNode.getValue().equals( "false" ) ); Attribute unqNode = node.attribute( "unique" ); if ( unqNode != null ) column.setUnique( unqNode.getValue().equals( "true" ) ); column.setCheckConstraint( node.attributeValue( "check" ) ); column.setDefaultValue( node.attributeValue( "default" ) ); Attribute typeNode = node.attribute( "sql-type" ); if ( typeNode != null ) column.setSqlType( typeNode.getValue() ); Element comment = node.element("comment"); if (comment!=null) column.setComment( comment.getTextTrim() ); }
Example #14
Source File: InFlightMetadataCollectorImpl.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void addColumnNameBinding(Table table, Identifier logicalName, Column column) throws DuplicateMappingException { TableColumnNameBinding binding = null; if ( columnNameBindingByTableMap == null ) { columnNameBindingByTableMap = new HashMap<>(); } else { binding = columnNameBindingByTableMap.get( table ); } if ( binding == null ) { binding = new TableColumnNameBinding( table.getName() ); columnNameBindingByTableMap.put( table, binding ); } binding.addBinding( logicalName, column ); }
Example #15
Source File: Ejb3Column.java From lams with GNU General Public License v2.0 | 6 votes |
public static Ejb3Column[] buildColumnFromAnnotation( javax.persistence.Column[] anns, org.hibernate.annotations.Formula formulaAnn, Nullability nullability, PropertyHolder propertyHolder, PropertyData inferredData, Map<String, Join> secondaryTables, MetadataBuildingContext context) { return buildColumnFromAnnotation( anns, formulaAnn, nullability, propertyHolder, inferredData, null, secondaryTables, context ); }
Example #16
Source File: MapBinder.java From lams with GNU General Public License v2.0 | 6 votes |
private String getFromAndWhereFormula( String tableName, Iterator<Selectable> collectionTableColumns, Iterator<Selectable> referencedEntityColumns) { String alias = "$alias$"; StringBuilder fromAndWhereSb = new StringBuilder( " from " ) .append( tableName ) //.append(" as ") //Oracle doesn't support it in subqueries .append( " " ) .append( alias ).append( " where " ); while ( collectionTableColumns.hasNext() ) { Column colColumn = (Column) collectionTableColumns.next(); Column refColumn = (Column) referencedEntityColumns.next(); fromAndWhereSb.append( alias ) .append( '.' ) .append( refColumn.getQuotedName() ) .append( '=' ) .append( colColumn.getQuotedName() ) .append( " and " ); } return fromAndWhereSb.substring( 0, fromAndWhereSb.length() - 5 ); }
Example #17
Source File: TableBinder.java From lams with GNU General Public License v2.0 | 6 votes |
public static void linkJoinColumnWithValueOverridingNameIfImplicit( PersistentClass referencedEntity, Iterator columnIterator, Ejb3JoinColumn[] columns, SimpleValue value) { for (Ejb3JoinColumn joinCol : columns) { Column synthCol = (Column) columnIterator.next(); if ( joinCol.isNameDeferred() ) { //this has to be the default value joinCol.linkValueUsingDefaultColumnNaming( synthCol, referencedEntity, value ); } else { joinCol.linkWithValue( value ); joinCol.overrideFromReferencedColumnIfNecessary( synthCol ); } } }
Example #18
Source File: Ejb3JoinColumn.java From lams with GNU General Public License v2.0 | 6 votes |
public void linkValueUsingDefaultColumnNaming( Column referencedColumn, PersistentClass referencedEntity, SimpleValue value) { String logicalReferencedColumn = getBuildingContext().getMetadataCollector().getLogicalColumnName( referencedEntity.getTable(), referencedColumn.getQuotedName() ); String columnName = buildDefaultColumnName( referencedEntity, logicalReferencedColumn ); //yuk side effect on an implicit column setLogicalColumnName( columnName ); setReferencedColumn( logicalReferencedColumn ); initMappingColumn( columnName, null, referencedColumn.getLength(), referencedColumn.getPrecision(), referencedColumn.getScale(), getMappingColumn() != null ? getMappingColumn().isNullable() : false, referencedColumn.getSqlType(), getMappingColumn() != null ? getMappingColumn().isUnique() : false, false ); linkWithValue( value ); }
Example #19
Source File: AbstractSchemaValidator.java From lams with GNU General Public License v2.0 | 5 votes |
protected void validateTable( Table table, TableInformation tableInformation, Metadata metadata, ExecutionOptions options, Dialect dialect) { if ( tableInformation == null ) { throw new SchemaManagementException( String.format( "Schema-validation: missing table [%s]", table.getQualifiedTableName().toString() ) ); } final Iterator selectableItr = table.getColumnIterator(); while ( selectableItr.hasNext() ) { final Selectable selectable = (Selectable) selectableItr.next(); if ( Column.class.isInstance( selectable ) ) { final Column column = (Column) selectable; final ColumnInformation existingColumn = tableInformation.getColumn( Identifier.toIdentifier( column.getQuotedName() ) ); if ( existingColumn == null ) { throw new SchemaManagementException( String.format( "Schema-validation: missing column [%s] in table [%s]", column.getName(), table.getQualifiedTableName() ) ); } validateColumnType( table, column, existingColumn, metadata, options, dialect ); } } }
Example #20
Source File: AbstractSchemaValidator.java From lams with GNU General Public License v2.0 | 5 votes |
protected void validateColumnType( Table table, Column column, ColumnInformation columnInformation, Metadata metadata, ExecutionOptions options, Dialect dialect) { boolean typesMatch = column.getSqlTypeCode( metadata ) == columnInformation.getTypeCode() || column.getSqlType( dialect, metadata ).toLowerCase(Locale.ROOT).startsWith( columnInformation.getTypeName().toLowerCase(Locale.ROOT) ); if ( !typesMatch ) { throw new SchemaManagementException( String.format( "Schema-validation: wrong column type encountered in column [%s] in " + "table [%s]; found [%s (Types#%s)], but expecting [%s (Types#%s)]", column.getName(), table.getQualifiedTableName(), columnInformation.getTypeName().toLowerCase(Locale.ROOT), JdbcTypeNameMapper.getTypeName( columnInformation.getTypeCode() ), column.getSqlType().toLowerCase(Locale.ROOT), JdbcTypeNameMapper.getTypeName( column.getSqlTypeCode( metadata ) ) ) ); } // this is the old Hibernate check... // // but I think a better check involves checks against type code and then the type code family, not // just the type name. // // See org.hibernate.type.descriptor.sql.JdbcTypeFamilyInformation // todo : this ^^ }
Example #21
Source File: StandardTableExporter.java From lams with GNU General Public License v2.0 | 5 votes |
protected void applyComments(Table table, QualifiedName tableName, List<String> sqlStrings) { if ( dialect.supportsCommentOn() ) { if ( table.getComment() != null ) { sqlStrings.add( "comment on table " + tableName + " is '" + table.getComment() + "'" ); } final Iterator iter = table.getColumnIterator(); while ( iter.hasNext() ) { Column column = (Column) iter.next(); String columnComment = column.getComment(); if ( columnComment != null ) { sqlStrings.add( "comment on column " + tableName + '.' + column.getQuotedName( dialect ) + " is '" + columnComment + "'" ); } } } }
Example #22
Source File: SpannerTableStatements.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 5 votes |
private List<String> getCreateTableStrings( Table table, Metadata metadata, Iterable<Column> keyColumns) { // Get the comma separated string of the primary keys of the table. String primaryKeyColNames = StreamSupport.stream(keyColumns.spliterator(), false) .map(Column::getQuotedName) .collect(Collectors.joining(",")); // Get the comma separated string of all columns of the table. Iterable<Column> columnIterable = () -> (Iterator<Column>) table.getColumnIterator(); String allColumnNames = StreamSupport.stream(columnIterable.spliterator(), false) .map(column -> buildColumnTypeString(column, metadata)) .collect(Collectors.joining(",")); ArrayList<String> statements = new ArrayList<>(); // Build the Create Table string. String createTableString = MessageFormat.format( CREATE_TABLE_TEMPLATE, table.getQuotedName(), allColumnNames, primaryKeyColNames, getInterleavedClause(table, metadata)); statements.add(createTableString); if (table.getName().equals(SequenceStyleGenerator.DEF_SEQUENCE_NAME)) { // Caches the INSERT statement since DML statements must be run after a DDL batch. addStatementAfterDdlBatch( metadata, "INSERT INTO " + SequenceStyleGenerator.DEF_SEQUENCE_NAME + " (" + SequenceStyleGenerator.DEF_VALUE_COLUMN + ") VALUES(1)"); } return statements; }
Example #23
Source File: IgniteCacheInitializer.java From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 | 5 votes |
private String fieldType(Column currentColumn) { Value value = currentColumn.getValue(); Type type = value.getType(); while ( type.isEntityType() || type.isComponentType() ) { if ( type.isEntityType() ) { type = ( (SimpleValue) value ).getMetadata().getIdentifierType( type.getName() ); } if ( type.isComponentType() ) { int i = 0; boolean columnFound = false; // search which nested property is mapped to the given column for ( Iterator<Selectable> ci = value.getColumnIterator(); ci.hasNext(); ++i ) { if ( currentColumn.getName().equals( ci.next().getText() ) ) { type = ( (ComponentType) type ).getSubtypes()[i]; columnFound = true; break; } } if ( !columnFound ) { throw new IllegalArgumentException( "Cannot determine type for column " + currentColumn ); } } } GridType gridType = serviceRegistry.getService( TypeTranslator.class ).getType( type ); if ( gridType instanceof EnumType ) { return enumFieldType( (EnumType) gridType ); } if ( gridType instanceof YesNoType ) { return STRING_CLASS_NAME; } if ( gridType instanceof NumericBooleanType ) { return INTEGER_CLASS_NAME; } Class<?> returnedClass = type.getReturnedClass(); if ( Character.class.equals( returnedClass ) ) { return STRING_CLASS_NAME; } return returnedClass.getName(); }
Example #24
Source File: InFlightMetadataCollectorImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") private List<Identifier> extractColumnNames(List columns) { if ( columns == null || columns.isEmpty() ) { return Collections.emptyList(); } final List<Identifier> columnNames = CollectionHelper.arrayList( columns.size() ); for ( Column column : (List<Column>) columns ) { columnNames.add( getDatabase().toIdentifier( column.getQuotedName() ) ); } return columnNames; }
Example #25
Source File: AbstractMultiTableBulkIdStrategyImpl.java From lams with GNU General Public License v2.0 | 5 votes |
protected String buildIdTableCreateStatement(Table idTable, JdbcServices jdbcServices, MetadataImplementor metadata) { final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); final Dialect dialect = jdbcEnvironment.getDialect(); StringBuilder buffer = new StringBuilder( getIdTableSupport().getCreateIdTableCommand() ) .append( ' ' ) .append( jdbcEnvironment.getQualifiedObjectNameFormatter().format( idTable.getQualifiedTableName(), dialect ) ) .append( " (" ); Iterator itr = idTable.getColumnIterator(); while ( itr.hasNext() ) { final Column column = (Column) itr.next(); buffer.append( column.getQuotedName( dialect ) ).append( ' ' ); buffer.append( column.getSqlType( dialect, metadata ) ); if ( column.isNullable() ) { buffer.append( dialect.getNullColumnString() ); } else { buffer.append( " not null" ); } if ( itr.hasNext() ) { buffer.append( ", " ); } } buffer.append( ") " ); if ( getIdTableSupport().getCreateIdTableStatementOptions() != null ) { buffer.append( getIdTableSupport().getCreateIdTableStatementOptions() ); } return buffer.toString(); }
Example #26
Source File: PersistentTableBulkIdStrategy.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected void augmentIdTableDefinition(Table idTable) { Column sessionIdColumn = new Column( Helper.SESSION_ID_COLUMN_NAME ); sessionIdColumn.setSqlType( "CHAR(36)" ); sessionIdColumn.setComment( "Used to hold the Hibernate Session identifier" ); idTable.addColumn( sessionIdColumn ); }
Example #27
Source File: AbstractDBUnitHibernateMemoryTest.java From livingdoc-confluence with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") protected String[] getColumnNames(Class<?> peristentClass, String[] includedFields) throws MappingException { Collection<String> columns = new ArrayList<String>(); for (int i = 0; i < includedFields.length; i++) { String propertyName = includedFields[i]; Property property = getMapping(peristentClass).getProperty(propertyName); for (Iterator<Column> it = property.getColumnIterator(); it.hasNext(); ) { Column col = it.next(); columns.add(col.getName()); } } return columns.toArray(new String[columns.size()]); }
Example #28
Source File: Mappings.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void addColumnBinding(String logicalName, Column finalColumn, Table table) { ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(table); if (binding == null) { binding = new ColumnNames(); columnNameBindingPerTable.put(table, binding); } String oldFinalName = (String) binding.logicalToPhysical.put( logicalName.toLowerCase(), finalColumn.getQuotedName() ); if ( oldFinalName != null && ! ( finalColumn.isQuoted() ? oldFinalName.equals( finalColumn.getQuotedName() ) : oldFinalName.equalsIgnoreCase( finalColumn.getQuotedName() ) ) ) { //TODO possibly relax that throw new MappingException("Same logical column name referenced by different physical ones: " + table.getName() + "." + logicalName + " => '" + oldFinalName + "' and '" + finalColumn.getQuotedName() + "'" ); } String oldLogicalName = (String) binding.physicalToLogical.put( finalColumn.getQuotedName(), logicalName ); if ( oldLogicalName != null && ! oldLogicalName.equals( logicalName ) ) { //TODO possibly relax that throw new MappingException("Same physical column represented by different logical column names: " + table.getName() + "." + finalColumn.getQuotedName() + " => '" + oldLogicalName + "' and '" + logicalName + "'"); } }
Example #29
Source File: SpannerTableExporter.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 5 votes |
/** * Processes the columns of the table and creates Unique Constraints for columns * annotated with @Column(unique = true). */ private static void initializeUniqueConstraints(Table table) { Iterator<Column> colIterator = table.getColumnIterator(); while (colIterator.hasNext()) { Column col = colIterator.next(); if (col.isUnique()) { String name = Constraint.generateName("UK_", table, col); UniqueKey uk = table.getOrCreateUniqueKey(name); uk.addColumn(col); } } }
Example #30
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void bindUniqueKey(Attribute uniqueKeyAttribute, Table table, Column column, Mappings mappings) { if ( uniqueKeyAttribute != null && table != null ) { StringTokenizer tokens = new StringTokenizer( uniqueKeyAttribute.getValue(), ", " ); while ( tokens.hasMoreTokens() ) { table.getOrCreateUniqueKey( tokens.nextToken() ).addColumn( column ); } } }