コード例 #1
0
 private Map<AssociationKeyMetadata, EmbeddedNeo4jAssociationQueries> initializeAssociationQueries(
     SessionFactoryImplementor sessionFactoryImplementor) {
   Map<AssociationKeyMetadata, EmbeddedNeo4jAssociationQueries> queryMap =
       new HashMap<AssociationKeyMetadata, EmbeddedNeo4jAssociationQueries>();
   Collection<CollectionPersister> collectionPersisters =
       sessionFactoryImplementor.getCollectionPersisters().values();
   for (CollectionPersister collectionPersister : collectionPersisters) {
     if (collectionPersister instanceof OgmCollectionPersister) {
       OgmCollectionPersister ogmCollectionPersister =
           (OgmCollectionPersister) collectionPersister;
       EntityKeyMetadata ownerEntityKeyMetadata =
           ((OgmEntityPersister) (ogmCollectionPersister.getOwnerEntityPersister()))
               .getEntityKeyMetadata();
       AssociationKeyMetadata associationKeyMetadata =
           ogmCollectionPersister.getAssociationKeyMetadata();
       queryMap.put(
           associationKeyMetadata,
           new EmbeddedNeo4jAssociationQueries(ownerEntityKeyMetadata, associationKeyMetadata));
     }
   }
   return queryMap;
 }
コード例 #2
0
  @Override
  public Set<AssociationKeyMetadata> getAllAssociationKeyMetadata() {
    Set<AssociationKeyMetadata> allAssociationKeyMetadata = new HashSet<>();

    for (CollectionPersister associationPersister : factory.getCollectionPersisters().values()) {
      allAssociationKeyMetadata.add(
          ((OgmCollectionPersister) associationPersister).getAssociationKeyMetadata());
    }

    for (EntityPersister entityPersister : factory.getEntityPersisters().values()) {
      for (String property : entityPersister.getPropertyNames()) {
        AssociationKeyMetadata inverseOneToOneAssociationKeyMetadata =
            ((OgmEntityPersister) entityPersister)
                .getInverseOneToOneAssociationKeyMetadata(property);
        if (inverseOneToOneAssociationKeyMetadata != null) {
          allAssociationKeyMetadata.add(inverseOneToOneAssociationKeyMetadata);
        }
      }
    }

    return allAssociationKeyMetadata;
  }