NH-3671

Note: Some dialects are doing SQL operations directly, and since they do not have a reference to the session or session factory, they cannot use this functionality.
_factory is consistent with the rest of the code... I can change everything to Factory, though