@RequiresSession
  public ArtifactEntity findByNameAndForeignKeys(String artifactName, TreeMap<String, String> foreignKeys) {
    //todo: need to update PK in DB
    TypedQuery<ArtifactEntity> query = entityManagerProvider.get()
        .createNamedQuery("artifactByNameAndForeignKeys", ArtifactEntity.class);
    query.setParameter("artifactName", artifactName);
    query.setParameter("foreignKeys", ArtifactEntity.serializeForeignKeys(foreignKeys));

    try {
      return query.getSingleResult();
    } catch (NoResultException ignored) {
      return null;
    }
  }
Find an artifact with the given name and foreign keys.

@param artifactName name of artifact to find
@param foreignKeys  foreign keys of artifact as json representation of
                    a map of key properties to values

@return  a matching artifact or null
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ArtifactDAO.java