コード例 #1
0
 private FilterSource[] determineFilterSources(PluralAssociationAttribute associationAttribute) {
   AnnotationInstance filtersAnnotation =
       JandexHelper.getSingleAnnotation(
           associationAttribute.annotations(), HibernateDotNames.FILTERS);
   List<FilterSource> filterSourceList = new ArrayList<FilterSource>();
   if (filtersAnnotation != null) {
     AnnotationInstance[] annotationInstances = filtersAnnotation.value().asNestedArray();
     for (AnnotationInstance filterAnnotation : annotationInstances) {
       FilterSource filterSource =
           new FilterSourceImpl(filterAnnotation, entityClass.getLocalBindingContext());
       filterSourceList.add(filterSource);
     }
   }
   AnnotationInstance filterAnnotation =
       JandexHelper.getSingleAnnotation(
           associationAttribute.annotations(), HibernateDotNames.FILTER);
   if (filterAnnotation != null) {
     FilterSource filterSource =
         new FilterSourceImpl(filterAnnotation, entityClass.getLocalBindingContext());
     filterSourceList.add(filterSource);
   }
   if (filterSourceList.isEmpty()) {
     return null;
   } else {
     return filterSourceList.toArray(new FilterSource[filterSourceList.size()]);
   }
 }
コード例 #2
0
 private static PluralAttributeElementSource determineElementSource(
     AttributeSource ownerAttributeSource,
     PluralAttributeSourceImpl pluralAttributeSource,
     ConfiguredClass entityClass,
     String relativePath) {
   if (ownerAttributeSource == null) {
     throw new AssertionFailure("ownerAssociationSource must be non-null.");
   }
   final PluralAssociationAttribute associationAttribute =
       pluralAttributeSource.pluralAssociationAttribute();
   switch (pluralAttributeSource.pluralAssociationAttribute().getNature()) {
     case MANY_TO_MANY:
       return associationAttribute.getMappedBy() == null
           ? new ManyToManyPluralAttributeElementSourceImpl(
               pluralAttributeSource, relativePath, entityClass.getLocalBindingContext())
           : new ManyToManyMappedByPluralAttributeElementSourceImpl(
               pluralAttributeSource, relativePath);
     case MANY_TO_ANY:
       return new ManyToAnyPluralAttributeElementSourceImpl(pluralAttributeSource, relativePath);
     case ONE_TO_MANY:
       boolean usesJoinTable =
           ownerAttributeSource.isSingular()
               ? ((ToOneAttributeSource) ownerAttributeSource).getContainingTableName() != null
               : ((PluralAttributeSource) ownerAttributeSource).usesJoinTable();
       if (usesJoinTable) {
         return associationAttribute.getMappedBy() == null
             ? new ManyToManyPluralAttributeElementSourceImpl(
                 pluralAttributeSource, relativePath, entityClass.getLocalBindingContext())
             : new ManyToManyMappedByPluralAttributeElementSourceImpl(
                 pluralAttributeSource, relativePath);
       } else {
         return associationAttribute.getMappedBy() == null
             ? new OneToManyPluralAttributeElementSourceImpl(pluralAttributeSource, relativePath)
             : new OneToManyMappedByPluralAttributeElementSourceImpl(
                 pluralAttributeSource, relativePath);
       }
     case ELEMENT_COLLECTION_BASIC:
       return new BasicPluralAttributeElementSourceImpl(
           associationAttribute, entityClass, relativePath);
     case ELEMENT_COLLECTION_EMBEDDABLE:
       {
         // TODO: cascadeStyles?
         return new CompositePluralAttributeElementSourceImpl(
             associationAttribute, entityClass, relativePath);
       }
   }
   throw new AssertionError(
       "Unexpected attribute nature for a association:" + associationAttribute.getNature());
 }
コード例 #3
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());
 }