diff --git a/src/palace/manager/celery/tasks/opds_odl.py b/src/palace/manager/celery/tasks/opds_odl.py index 03d8a1b45..ecb3db3d8 100644 --- a/src/palace/manager/celery/tasks/opds_odl.py +++ b/src/palace/manager/celery/tasks/opds_odl.py @@ -218,14 +218,14 @@ def collect_events( """ with task.session() as session: for e in events: - session.refresh(e.library) - session.refresh(e.license_pool) - session.refresh(e.patron) + library = session.merge(e.library) + license_pool = session.merge(e.license_pool) + patron = session.merge(e.patron) analytics.collect_event( event_type=e.event_type, - library=e.library, - license_pool=e.license_pool, - patron=e.patron, + library=library, + license_pool=license_pool, + patron=patron, )