@Override public Class<? extends CollectionPersister> getCollectionPersisterClass(Collection metadata) { return metadata.isOneToMany() ? oneToManyPersister() : basicCollectionPersister(); }
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() ); } }
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 ); } }
protected void createBackReferences() { if ( collectionBinding.isOneToMany() && !collectionBinding.isInverse() && !collectionBinding.getKey().isNullable() ) { // for non-inverse one-to-many, with a not-null fk, add a backref! String entityName = ( (OneToMany) collectionBinding.getElement() ).getReferencedEntityName(); PersistentClass referenced = mappingDocument.getMetadataCollector().getEntityBinding( entityName ); Backref prop = new Backref(); prop.setName( '_' + collectionBinding.getOwnerEntityName() + "." + pluralAttributeSource.getName() + "Backref" ); prop.setUpdateable( false ); prop.setSelectable( false ); prop.setCollectionRole( collectionBinding.getRole() ); prop.setEntityName( collectionBinding.getOwner().getEntityName() ); prop.setValue( collectionBinding.getKey() ); referenced.addProperty( prop ); log.debugf( "Added virtual backref property [%s] : %s", prop.getName(), pluralAttributeSource.getAttributeRole().getFullPath() ); } }
if ( !collection.isOneToMany() ) {
@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() ) ); } } }
if ( collectionBinding.isOneToMany() ) { throw new MappingException( "one-to-many collections with identifiers are not supported" );
public boolean isOneToMany(Value value) { if(value instanceof Collection) { return ( (Collection)value ).isOneToMany(); }else if(value instanceof OneToMany){ return true; } return false; }
public boolean isOneToMany(Value value) { if(value instanceof Collection) { return ( (Collection)value ).isOneToMany(); }else if(value instanceof OneToMany){ return true; } return false; }
@Override public Class<? extends CollectionPersister> getCollectionPersisterClass(Collection metadata) { return metadata.isOneToMany() ? CustomOneToManyPersister.class : CustomBasicCollectionPersister.class; }
@Override public Class<? extends CollectionPersister> getCollectionPersisterClass(Collection metadata) { return metadata.isOneToMany() ? CustomOneToManyPersister.class : CustomBasicCollectionPersister.class; }
@Override public Class<? extends CollectionPersister> getCollectionPersisterClass(Collection metadata) { return metadata.isOneToMany() ? CustomOneToManyPersister.class : CustomBasicCollectionPersister.class; }
@Override public Class<? extends CollectionPersister> getCollectionPersisterClass(Collection metadata) { return metadata.isOneToMany() ? CustomOneToManyPersister.class : CustomBasicCollectionPersister.class; }
@Override public Class<? extends CollectionPersister> getCollectionPersisterClass(Collection metadata) { return metadata.isOneToMany() ? CustomOneToManyPersister.class : CustomBasicCollectionPersister.class; }
@Override public Class<? extends CollectionPersister> getCollectionPersisterClass(Collection metadata) { return metadata.isOneToMany() ? CustomOneToManyPersister.class : CustomBasicCollectionPersister.class; }
@Override public Class<? extends CollectionPersister> getCollectionPersisterClass(Collection metadata) { return metadata.isOneToMany() ? CustomOneToManyPersister.class : CustomBasicCollectionPersister.class; }
@Override public Class<? extends CollectionPersister> getCollectionPersisterClass(Collection metadata) { return metadata.isOneToMany() ? oneToManyPersister() : basicCollectionPersister(); }
if ( !collection.isOneToMany() ) {
public static CollectionPersister createCollectionPersister(Configuration cfg, Collection model, CacheConcurrencyStrategy cache, SessionFactoryImplementor factory) throws HibernateException { Class persisterClass = model.getCollectionPersisterClass(); if(persisterClass==null) { // default behavior return model.isOneToMany() ? (CollectionPersister) new OneToManyPersister(model, cache, cfg, factory) : (CollectionPersister) new BasicCollectionPersister(model, cache, cfg, factory); } else { return create(persisterClass, cfg, model, cache, factory); } }
public static CollectionPersister createCollectionPersister(Configuration cfg, Collection model, CacheConcurrencyStrategy cache, SessionFactoryImplementor factory) throws HibernateException { Class persisterClass = model.getCollectionPersisterClass(); if(persisterClass==null) { // default behavior return model.isOneToMany() ? (CollectionPersister) new OneToManyPersister(model, cache, cfg, factory) : (CollectionPersister) new BasicCollectionPersister(model, cache, cfg, factory); } else { return create(persisterClass, cfg, model, cache, factory); } }