Compartment::getRoomEndpoints() sometimes skips RoomEndpoints because they are fetched lazily. Hence, they are not instances of RoomEndpoint but HibernateProxy#RoomEndpoint instead.
@Transient
public List<RoomEndpoint> getRoomEndpoints()
{
List<RoomEndpoint> roomEndpoints = new ArrayList<RoomEndpoint>();
for (Executable childExecutable : getChildExecutables()) {
if (!(childExecutable instanceof RoomEndpoint)) {
continue;
}
RoomEndpoint roomEndpoint = (RoomEndpoint) childExecutable;
roomEndpoints.add(roomEndpoint);
}
return roomEndpoints;
}
While adding getLazyImplementation() to unproxy and resolving this problem, I found another problem in RoomEndpoint::toApi(), which uses the executable_summary table, and there is no given RoomEndpoint yet.
(executable_summary table is updated manually using Executable::updateExecutableSummary())
// RoomEndpoint::toApi()
// Determine whether room has recording service and recordings
// (use executable_summary for used_room_endpoints to be taken into account)
// Sometimes there is no data yet in executable_summary, so we must use the original query (see below)
Object[] result = (Object[]) entityManager.createNativeQuery(
"SELECT room_has_recording_service, room_has_recordings FROM executable_summary WHERE id = :id")
.setParameter("id", getId())
.getSingleResult();
public void updateExecutableSummary(EntityManager entityManager, boolean deleteOnly)
{
entityManager.flush();
ExecutableManager executableManager = new ExecutableManager(entityManager);
executableManager.updateExecutableSummary(this, deleteOnly);
}
For now, as a workaround, we can either use executable_summary_view or join the tables directly:
"SELECT room_has_recording_service, room_has_recordings FROM executable_summary_view WHERE id = :id"
// or
"""
SELECT
COUNT(recording_service.id) > 0 AS room_has_recording_service,
COUNT(recording_service.id) > 0 OR COUNT(resource_room_endpoint_recording_folder_ids.recording_folder_id) > 0 AS room_has_recordings
FROM used_room_endpoint
LEFT JOIN used_room_endpoint AS room_endpoint_usage ON room_endpoint_usage.room_endpoint_id = :id
LEFT JOIN executable_service ON executable_service.executable_id = :id OR executable_service.executable_id = room_endpoint_usage.id
LEFT JOIN recording_service ON recording_service.id = executable_service.id
LEFT JOIN resource_room_endpoint_recording_folder_ids ON resource_room_endpoint_recording_folder_ids.resource_room_endpoint_id = :id OR resource_room_endpoint_recording_folder_ids.resource_room_endpoint_id = used_room_endpoint.room_endpoint_id
WHERE used_room_endpoint.id = :id
"""
Compartment::getRoomEndpoints()sometimes skipsRoomEndpointsbecause they are fetched lazily. Hence, they are not instances ofRoomEndpointbutHibernateProxy#RoomEndpointinstead.While adding
getLazyImplementation()tounproxyand resolving this problem, I found another problem inRoomEndpoint::toApi(), which uses theexecutable_summarytable, and there is no given RoomEndpoint yet.(
executable_summarytable is updated manually usingExecutable::updateExecutableSummary())For now, as a workaround, we can either use
executable_summary_viewor join the tables directly: