@Override public boolean usesJoinTable() { if (associationAttribute.getMappedBy() != null) { throw new IllegalStateException( "Cannot determine if a join table is used because plural attribute is not the owner."); } // By default, a unidirectional one-to-many (i.e., with mappedBy == null) uses a join table, // unless it has join columns defined. return associationAttribute.getJoinTableAnnotation() != null || (associationAttribute.getJoinTableAnnotation() == null && associationAttribute.getJoinColumnValues().size() == 0); }
@Override public TableSpecificationSource getCollectionTableSpecificationSource() { // todo - see org.hibernate.metamodel.internal.Binder#bindOneToManyCollectionKey // todo - needs to cater for @CollectionTable and @JoinTable if (associationAttribute.getMappedBy() != null) { throw new IllegalStateException( "Cannot get collection table because this association is not the owner."); } final AnnotationInstance joinTableAnnotation = associationAttribute.getJoinTableAnnotation(); return joinTableAnnotation == null ? null : new TableSourceImpl(joinTableAnnotation, entityClass.getLocalBindingContext()); }