/** * Returns whether we believe the map element should be included as part of the middle table's primary key. * * @return {@code true} if the element should be included as part of the key, otherwise {@code false}. */ private boolean isMapElementInPrimaryKey() { if ( propertyValue instanceof IndexedCollection ) { final Value index = ( (IndexedCollection) propertyValue ).getIndex(); return !index.getType().isEntityType(); } return true; } }
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() ); } }
private Class determineKeyClass(XClass keyXClass) { if ( keyXClass != null ) { try { return getContext().getBootstrapContext().getReflectionManager().toClass( keyXClass ); } catch (Exception e) { log.debugf( "Unable to resolve XClass [%s] to Class for collection key [%s]", keyXClass.getName(), collection.getRole() ); } } final IndexedCollection indexedCollection = (IndexedCollection) collection; if ( indexedCollection.getIndex() != null ) { if ( indexedCollection.getIndex().getType() != null ) { return indexedCollection.getIndex().getType().getReturnedClass(); } } // currently this is called from paths where the element type really should be known, // so log the fact that we could not resolve the collection element info log.debugf( "Unable to resolve key information for collection [%s]", collection.getRole() ); return null; } }
private void checkColumnDuplication() throws MappingException { HashSet cols = new HashSet(); checkColumnDuplication( cols, getKey() ); if ( isIndexed() ) { checkColumnDuplication( cols, ( (IndexedCollection) this ).getIndex() ); } if ( isIdentified() ) { checkColumnDuplication( cols, ( (IdentifierCollection) this ).getIdentifier() ); } if ( !isOneToMany() ) { checkColumnDuplication( cols, getElement() ); } }
indexedValue.getIndex(), middleEntityXml, queryGeneratorBuilder,
public void doSecondPass(java.util.Map persistentClasses) throws MappingException { final boolean debugEnabled = LOG.isDebugEnabled(); if ( debugEnabled ) { LOG.debugf( "Second pass for collection: %s", collection.getRole() ); } secondPass( persistentClasses, localInheritedMetas ); // using local since the inheritedMetas at this point is not the correct map since it is always the empty map collection.createAllKeys(); if ( debugEnabled ) { String msg = "Mapped collection key: " + columns( collection.getKey() ); if ( collection.isIndexed() ) msg += ", index: " + columns( ( (IndexedCollection) collection ).getIndex() ); if ( collection.isOneToMany() ) { msg += ", one-to-many: " + ( (OneToMany) collection.getElement() ).getReferencedEntityName(); } else { msg += ", element: " + columns( collection.getElement() ); } LOG.debug( msg ); } }
final boolean indexed = ( propertyValue instanceof IndexedCollection ) && ( (IndexedCollection) propertyValue ).getIndex() != null; final Value indexValue = ( (IndexedCollection) propertyValue ).getIndex(); positionMappedBy = indexValue.getColumnIterator().next().getText(); final Type indexType; if ( IndexedCollection.class.isInstance( propertyValue ) ) { indexType = ( (IndexedCollection) propertyValue ).getIndex().getType();
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 ); } }
indexType = indexedCollection.getIndex().getType(); int indexSpan = indexedCollection.getIndex().getColumnSpan(); boolean[] indexColumnInsertability = indexedCollection.getIndex().getColumnInsertability(); boolean[] indexColumnUpdatability = indexedCollection.getIndex().getColumnUpdateability(); iter = indexedCollection.getIndex().getColumnIterator(); indexColumnNames = new String[indexSpan]; indexFormulaTemplates = new String[indexSpan];
@Override public void doSecondPass(Map persistentClasses) throws org.hibernate.MappingException { bindCollectionTable(); bindCollectionKey(); bindCollectionIdentifier(); bindCollectionIndex(); bindCollectionElement(); createBackReferences(); collectionBinding.createAllKeys(); if ( debugEnabled ) { log.debugf( "Mapped collection : " + getPluralAttributeSource().getAttributeRole().getFullPath() ); log.debugf( " + table -> " + getCollectionBinding().getTable().getName() ); log.debugf( " + key -> " + columns( getCollectionBinding().getKey() ) ); if ( getCollectionBinding().isIndexed() ) { log.debugf( " + index -> " + columns( ( (IndexedCollection) getCollectionBinding() ).getIndex() ) ); } if ( getCollectionBinding().isOneToMany() ) { log.debugf( " + one-to-many -> " + ( (OneToMany) getCollectionBinding().getElement() ).getReferencedEntityName() ); } else { log.debugf( " + element -> " + columns( getCollectionBinding().getElement() ) ); } } }
private JavaTypeDescriptor getCollectionIndexJavaTypeDescriptor() { if ( !IndexedCollection.class.isInstance( propertyValue ) ) { return null; } return ( (IndexedCollection ) propertyValue ).getIndex().getJavaTypeMapping().getJavaTypeDescriptor(); }
public CollectionIndexEmbeddedImpl( PersistentCollectionDescriptor descriptor, IndexedCollection bootCollectionMapping, RuntimeModelCreationContext creationContext) { super( descriptor ); this.embeddedDescriptor = creationContext.getRuntimeModelDescriptorFactory().createEmbeddedTypeDescriptor( (EmbeddedValueMappingImplementor) bootCollectionMapping.getIndex(), descriptor, null, NAVIGABLE_NAME, SingularPersistentAttribute.Disposition.NORMAL, creationContext ); }
public void validate(Mapping mapping) throws MappingException { super.validate(mapping); if ( !getIndex().isValid(mapping) ) { throw new MappingException( "collection index mapping has wrong number of columns: " + getRole() + " type: " + getIndex().getType().getName() ); } if ( indexNodeName!=null && !indexNodeName.startsWith("@") ) { throw new MappingException("index node must be an attribute: " + indexNodeName ); } }
public void validate(Mapping mapping) throws MappingException { super.validate(mapping); if ( !getIndex().isValid(mapping) ) { throw new MappingException( "collection index mapping has wrong number of columns: " + getRole() + " type: " + getIndex().getType().getName() ); } if ( indexNodeName!=null && !indexNodeName.startsWith("@") ) { throw new MappingException("index node must be an attribute: " + indexNodeName ); } }
public void validate(Mapping mapping) throws MappingException { super.validate(mapping); if ( !getIndex().isValid(mapping) ) { throw new MappingException( "collection index mapping has wrong number of columns: " + getRole() + " type: " + getIndex().getType().getName() ); } if ( indexNodeName!=null && !indexNodeName.startsWith("@") ) { throw new MappingException("index node must be an attribute: " + indexNodeName ); } }
public void validate(Mapping mapping) throws MappingException { super.validate(mapping); if ( !getIndex().isValid(mapping) ) { throw new MappingException( "collection index mapping has wrong number of columns: " + getRole() + " type: " + getIndex().getType().getName() ); } if ( indexNodeName!=null && !indexNodeName.startsWith("@") ) { throw new MappingException("index node must be an attribute: " + indexNodeName ); } }
private void createCollectionKeys() { collection.createAllKeys(); if (LOG.isDebugEnabled()) { String msg = "Mapped collection key: " + columns(collection.getKey()); if (collection.isIndexed()) msg += ", index: " + columns(((IndexedCollection) collection).getIndex()); if (collection.isOneToMany()) { msg += ", one-to-many: " + ((OneToMany) collection.getElement()).getReferencedEntityName(); } else { msg += ", element: " + columns(collection.getElement()); } LOG.debug(msg); } }
public String getGenericCollectionDeclaration(Collection collection, boolean preferRawTypeNames, ImportContext importContext) { Value element = collection.getElement(); String elementType = importContext.importType(getJavaTypeName(element, preferRawTypeNames)); String genericDecl = elementType; if(collection.isIndexed()) { IndexedCollection idxCol = (IndexedCollection) collection; if(!idxCol.isList()) { Value idxElement = idxCol.getIndex(); String indexType = importContext.importType(getJavaTypeName(idxElement, preferRawTypeNames)); genericDecl = indexType + "," + elementType; } } String decl = "<" + genericDecl + ">"; return decl; }
public String getGenericCollectionDeclaration(Collection collection, boolean preferRawTypeNames, ImportContext importContext) { Value element = collection.getElement(); String elementType = importContext.importType(getJavaTypeName(element, preferRawTypeNames)); String genericDecl = elementType; if(collection.isIndexed()) { IndexedCollection idxCol = (IndexedCollection) collection; if(!idxCol.isList()) { Value idxElement = idxCol.getIndex(); String indexType = importContext.importType(getJavaTypeName(idxElement, preferRawTypeNames)); genericDecl = indexType + "," + elementType; } } String decl = "<" + genericDecl + ">"; return decl; }