collValue.setCollectionTable( associationTableBinder.bind() );
}
bindFilters( isCollectionOfEntities );
bindCollectionSecondPass( collValue, collectionEntity, joinColumns, cascadeDeleteEnabled, property, mappings );
ManyToOne element = null;
if ( isCollectionOfEntities ) {
element =
new ManyToOne( mappings, collValue.getCollectionTable() );
collValue.setElement( element );
element.setReferencedEntityName( collType.getName() );
//element.setFetchMode( fetchMode );
//element.setLazy( fetchMode != FetchMode.JOIN );
//make the second join non lazy
element.setFetchMode( FetchMode.JOIN );
element.setLazy( false );
element.setIgnoreNotFound( ignoreNotFound );
// as per 11.1.38 of JPA 2.0 spec, default to primary key if no column is specified by @OrderBy.
if ( hqlOrderBy != null ) {
collValue.setManyToManyOrdering(
buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() )
);
}
final ForeignKey fk = property.getAnnotation( ForeignKey.class );
String fkName = fk != null ? fk.inverseName() : "";
if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) {
element.setForeignKeyName( fkName );
}
}
else if ( anyAnn != null ) {
//@ManyToAny
//Make sure that collTyp is never used during the @ManyToAny branch: it will be set to void.class