public java.util.List<MappedColumn> getConstraintColumns() { final ArrayList<MappedColumn> list = new ArrayList(); identifier.getMappedColumns().forEach( o -> list.add( (MappedColumn) o ) ); return list; } /**
@Override public List<MappedColumn> getMappedColumns() { return Collections.unmodifiableList( associatedClass.getKey().getMappedColumns() ); }
public void doSecondPass(Map persistentClasses) throws MappingException { PersistentClass referencedEntity = (PersistentClass) persistentClasses.get( referencedEntityName ); if ( referencedEntity == null ) { throw new AnnotationException( "Unknown entity name: " + referencedEntityName ); } TableBinder.linkJoinColumnWithValueOverridingNameIfImplicit( referencedEntity, referencedEntity.getKey().getMappedColumns(), columns, value); } }
@Override public Boolean resolve(ResolutionContext context) { Iterator<MappedColumn> columnsIterator = columns.iterator(); List<Column> wrappedValueColumns = wrappedValue.getMappedColumns(); for ( Column wrappedValueColumn : wrappedValueColumns ) { if ( wrappedValueColumn.getJavaTypeMapping() == null ) { return false; } Column column = (Column) columnsIterator.next(); column.setJavaTypeMapping( wrappedValueColumn.getJavaTypeMapping() ); column.setSqlTypeDescriptorAccess( wrappedValueColumn::getSqlTypeDescriptor ); } return true; }
@SuppressWarnings({"unchecked"}) private String searchMappedBy(PersistentClass referencedClass, Collection collectionValue) { final Iterator<Property> assocClassProps = referencedClass.getPropertyIterator(); while ( assocClassProps.hasNext() ) { final Property property = assocClassProps.next(); if ( property.getValue().getMappedColumns().equals( collectionValue.getKey().getMappedColumns() ) ) { return property.getName(); } } // HHH-7625 // Support ToOne relations with mappedBy that point to an @IdClass key property. return searchMappedByKey( referencedClass, collectionValue ); }
@SuppressWarnings({"unchecked"}) private String searchMappedByKey(PersistentClass referencedClass, Collection collectionValue) { final Iterator<Value> assocIdClassProps = referencedClass.getKeyClosureIterator(); while ( assocIdClassProps.hasNext() ) { final Value value = assocIdClassProps.next(); // make sure its a 'Component' because IdClass is registered as this type. if ( value instanceof Component ) { final Component component = (Component) value; List<PersistentAttributeMapping> declaredPersistentAttributes = component.getDeclaredPersistentAttributes(); for ( PersistentAttributeMapping attribute : declaredPersistentAttributes ) { if ( ( (List<MappedColumn>) attribute.getValueMapping().getMappedColumns() ) .equals( collectionValue.getKey().getMappedColumns() ) ) { return attribute.getName(); } } } } return null; }
protected void checkColumnDuplication() { HashSet cols = new HashSet(); if ( getEntityMappingHierarchy().getIdentifierEmbeddedValueMapping() == null ) { //an identifier mapper => getKey will be included in the getNonDuplicatedPropertyIterator() //and checked later, so it needs to be excluded checkColumnDuplication( cols, getKey().getMappedColumns() ); } checkColumnDuplication( cols, getDiscriminatorColumns() ); checkPropertyColumnDuplication( cols, getNonDuplicatedPropertyIterator() ); joins.forEach( join -> { cols.clear(); checkColumnDuplication( cols, join.getKey().getMappedColumns() ); checkPropertyColumnDuplication( cols, join.getPropertyIterator() ); } ); }
public void createPrimaryKey() { //Primary key constraint MappedPrimaryKey pk = new PrimaryKey( table ); pk.setName( PK_ALIAS.toAliasString( table.getName() ) ); table.setPrimaryKey(pk); pk.addColumns( getKey().getMappedColumns() ); }
void createPrimaryKey() { if ( !isOneToMany() ) { MappedPrimaryKey pk = new PrimaryKey( getMappedTable() ); pk.addColumns( getIdentifier().getMappedColumns() ); getMappedTable().setPrimaryKey(pk); } // create an index on the key columns?? }
public void createPrimaryKey() { //Primary key constraint final MappedTable table = getMappedTable(); MappedPrimaryKey pk = new PrimaryKey( table ); pk.setName( PK_ALIAS.toAliasString( table.getName() ) ); table.setPrimaryKey( pk ); pk.addColumns( getKey().getMappedColumns() ); }
List<MappedColumn> mappedByColumns; if ( property.getValue() instanceof Collection ) { mappedByColumns = ( (Collection) property.getValue() ).getKey().getMappedColumns(); key = property.getPersistentClass().getIdentifier(); mappedByColumns = key.getMappedColumns();
MetadataTools.addColumns( joinKey, join.getKey().getMappedColumns() ); MetadataTools.addColumn( joinKey, options.getRevisionFieldName(), null, null, null, null, null, null );
List<MappedColumn> mappedColumns = referencedEntity.getKey().getMappedColumns(); mappedColumns.forEach( column -> idColumns.add( column ));
final List<MappedColumn> mappedColumns = identifier.getMappedColumns(); final List<Identifier> idColumnNames = new ArrayList<>(); if ( identifier.getColumnSpan() != joinColumns.length ) {
void createPrimaryKey() { if ( !isOneToMany() ) { final MappedPrimaryKey pk = new PrimaryKey( getMappedTable() ); pk.addColumns( getKey().getMappedColumns() ); for ( Object selectable : getElement().getMappedColumns() ) { if ( selectable instanceof Column ) { Column col = (Column) selectable; if ( !col.isNullable() ) { pk.addColumn( col ); } else { return; } } } if ( pk.getColumnSpan() == getKey().getColumnSpan() ) { //for backward compatibility, allow a set with no not-null //element columns, using all columns in the row locater SQL //TODO: create an implicit not null constraint on all cols? } else { getMappedTable().setPrimaryKey( pk ); } } else { //create an index on the key columns?? } }
void createPrimaryKey() { if ( !isOneToMany() ) { final MappedPrimaryKey pk = new PrimaryKey( getMappedTable() ); pk.addColumns( getKey().getMappedColumns() ); // index should be last column listed boolean isFormula = false; for( MappedColumn selectable : (List<MappedColumn>) getIndex().getMappedColumns() ){ if(selectable.isFormula()){ isFormula = true; } } if (isFormula) { //if it is a formula index, use the element columns in the PK pk.addColumns( getElement().getMappedColumns() ); } else { pk.addColumns( getIndex().getMappedColumns() ); } getMappedTable().setPrimaryKey(pk); } else { // don't create a unique key, 'cos some // databases don't like a UK on nullable // columns /*ArrayList list = new ArrayList(); list.addAll( getKey().getConstraintColumns() ); list.addAll( getIndex().getConstraintColumns() ); getCollectionTable().createUniqueKey(list);*/ } }
referencedEntityColumns = associatedClass.getIdentifier().getMappedColumns(); targetPropertyPersistentClass.getMappedTable().getQualifiedTableName().toString(), element.getMappedColumns(), associatedClass.getIdentifier().getMappedColumns() );
manyToOne.setUnwrapProxy( value.isUnwrapProxy() ); prop.setValue( manyToOne ); otherSideJoin.get().getKey().getMappedColumns() .forEach( column -> manyToOne.addColumn( ( (Column) column ).clone() ) ); manyToOne.createForeignKey();
(MappedColumn) identifierCollection.getIdentifier().getMappedColumns().get( 0 ) );
MetadataTools.getColumnNameIterator( propertyValue.getKey().getMappedColumns() ), referencingIdMapping );