public void validate(Mapping mapping) throws MappingException { super.validate( mapping ); assert getElement() != null : "IndexedCollection index not bound : " + getRole(); if ( !getIndex().isValid(mapping) ) { throw new MappingException( "collection index mapping has wrong number of columns: " + getRole() + " type: " + getIndex().getType().getName() ); } }
pk.addColumns( getElement().getColumnIterator() );
private void createIndexBackRef( MappingDocument mappingDocument, IndexedPluralAttributeSource pluralAttributeSource, IndexedCollection collectionBinding) { if ( collectionBinding.isOneToMany() && !collectionBinding.getKey().isNullable() && !collectionBinding.isInverse() ) { final String entityName = ( (OneToMany) collectionBinding.getElement() ).getReferencedEntityName(); final PersistentClass referenced = mappingDocument.getMetadataCollector().getEntityBinding( entityName ); final IndexBackref ib = new IndexBackref(); ib.setName( '_' + collectionBinding.getOwnerEntityName() + "." + pluralAttributeSource.getName() + "IndexBackref" ); ib.setUpdateable( false ); ib.setSelectable( false ); ib.setCollectionRole( collectionBinding.getRole() ); ib.setEntityName( collectionBinding.getOwner().getEntityName() ); ib.setValue( collectionBinding.getIndex() ); referenced.addProperty( ib ); } }
void createPrimaryKey() { if ( !isOneToMany() ) { PrimaryKey pk = new PrimaryKey(); pk.addColumns( getKey().getColumnIterator() ); // index should be last column listed boolean isFormula = false; Iterator iter = getIndex().getColumnIterator(); while ( iter.hasNext() ) { if ( ( (Selectable) iter.next() ).isFormula() ) isFormula=true; } if (isFormula) { //if it is a formula index, use the element columns in the PK pk.addColumns( getElement().getColumnIterator() ); } else { pk.addColumns( getIndex().getColumnIterator() ); } getCollectionTable().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);*/ } }
void createPrimaryKey() { if ( !isOneToMany() ) { PrimaryKey pk = new PrimaryKey(); pk.addColumns( getKey().getColumnIterator() ); // index should be last column listed boolean isFormula = false; Iterator iter = getIndex().getColumnIterator(); while ( iter.hasNext() ) { if ( ( (Selectable) iter.next() ).isFormula() ) isFormula=true; } if (isFormula) { //if it is a formula index, use the element columns in the PK pk.addColumns( getElement().getColumnIterator() ); } else { pk.addColumns( getIndex().getColumnIterator() ); } getCollectionTable().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);*/ } }
void createPrimaryKey() { if ( !isOneToMany() ) { PrimaryKey pk = new PrimaryKey(); pk.addColumns( getKey().getColumnIterator() ); // index should be last column listed boolean isFormula = false; Iterator iter = getIndex().getColumnIterator(); while ( iter.hasNext() ) { if ( ( (Selectable) iter.next() ).isFormula() ) isFormula=true; } if (isFormula) { //if it is a formula index, use the element columns in the PK pk.addColumns( getElement().getColumnIterator() ); } else { pk.addColumns( getIndex().getColumnIterator() ); } getCollectionTable().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);*/ } }
void createPrimaryKey() { if ( !isOneToMany() ) { PrimaryKey pk = new PrimaryKey(); pk.addColumns( getKey().getColumnIterator() ); // index should be last column listed boolean isFormula = false; Iterator iter = getIndex().getColumnIterator(); while ( iter.hasNext() ) { if ( ( (Selectable) iter.next() ).isFormula() ) isFormula=true; } if (isFormula) { //if it is a formula index, use the element columns in the PK pk.addColumns( getElement().getColumnIterator() ); } else { pk.addColumns( getIndex().getColumnIterator() ); } getCollectionTable().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);*/ } }
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);*/ } }
private void createIndexBackRef( MappingDocument mappingDocument, IndexedPluralAttributeSource pluralAttributeSource, IndexedCollection collectionBinding) { if ( collectionBinding.isOneToMany() && !collectionBinding.getKey().isNullable() && !collectionBinding.isInverse() ) { final String entityName = ( (OneToMany) collectionBinding.getElement() ).getReferencedEntityName(); final PersistentClass referenced = mappingDocument.getMetadataCollector().getEntityBinding( entityName ); final IndexBackref ib = new IndexBackref( metadataBuildingContext ); ib.setName( '_' + collectionBinding.getOwnerEntityName() + "." + pluralAttributeSource.getName() + "IndexBackref" ); ib.setUpdateable( false ); ib.setSelectable( false ); ib.setCollectionRole( collectionBinding.getRole() ); ib.setEntityName( collectionBinding.getOwner().getEntityName() ); ib.setValue( collectionBinding.getIndex() ); referenced.addProperty( ib ); } }