"Hypnotic" literally just means "sleep-inducing".
So this class includes an extremely wide range of substances with a number of different mechanisms of action: benzodiazepines, antihistamines, melatonin, bromide salts, barbiturates, GHB, chloral hydrate, valerian, and many others... even ethanol could be considered a "hypnotic" drug (indeed, it has historically been arguably the most popular means of self-medicating for insomnia), as could morphine (after all, its name comes from the Greek god of dreams).
Doxylamine and diphenhydramine are considered "hypnotics" today because 1st generation antihistamines have largely been replaced as allergy medication by newer, peripherally acting antihistamines like loratadine (which lack the sedating side-effects of their predecessors), relegating these old-timey antihistamines to being mostly used as sleep aids.
Now, it is possible that relative to the desirable sedation, doxylamine could produce less unwanted side-effects, but someone with a serious tolerance to antihistamines (or just plain desperation due to a painful opioid withdrawal) might very well still find themselves taking enough to experience the effects of excessive anticholinergic action.