Classical novae are among the most frequent transient events in the Milky Way, and key agents of ongoing nucleosynthesis. Despite their large numbers, they have never been observed in soft $gamma$-ray emission. Measurements of their $gamma$-ray signatures would provide both, insights on explosion mechanism as well as nucleosynthesis products. Our goal is to constrain the ejecta masses of $mathrm{^7Be}$ and $mathrm{^{22}Na}$ from classical novae through their $gamma$-ray line emissions at 478 and 1275 keV. We extract posterior distributions on the line fluxes from archival data of the INTEGRAL/SPI spectrometer telescope. We then use a Bayesian hierarchical model to link individual objects and diffuse emission and infer ejecta masses from the whole population of classical novae in the Galaxy. Individual novae are too dim to be detectable in soft $gamma$-rays, and the upper bounds on their flux and ejecta mass uncertainties cover several orders of magnitude. Within the framework of our hierarchical model, we can, nevertheless, infer tight upper bounds on the $mathrm{^{22}Na}$ ejecta masses, given all uncertainties from individual objects as well as diffuse emission, of $<2.0 times 10^{-7},mathrm{M_{odot}}$ (99.85th percentile). In the context of ONe nucleosynthesis, the $mathrm{^{22}Na}$ bounds are consistent with theoretical expectations, and exclude that most ONe novae happen on white dwarfs with masses around $1.35,mathrm{M_{odot}}$. The upper bounds from $mathrm{^{7}Be}$ are uninformative. From the combined ejecta mass estimate of $mathrm{^{22}Na}$ and its $beta^+$-decay, we infer a positron production rate of $<5.5 times 10^{42},mathrm{e^+,s^{-1}}$, which would make at most 10% of the total annihilation rate in the Milky Way.