Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Resolved LazyInitializationException in TimeEntry retrieval. (Close
#13) # Issue We encountered a `LazyInitializationException` when trying to access the `timeSegmentList` of a `TimeEntry` object that was retrieved from the cache. This happened because the `timeSegmentList` was lazily loaded by Hibernate, and we were trying to access it after the Hibernate Session had been closed. # Temporary Solution We resolved this issue by forcing the initialization of the `timeSegmentList` before caching the `TimeEntry` object. We did this by calling `size()` on the `timeSegmentList` in the `getTimeEntryById` method. This ensured that the list was fetched from the database and included in the cached `TimeEntry`. ```java timeEntry.getTimeSegmentList().size(); // This will initialize the timeSegmentList ``` > ## Note > This solution might have performance implications if the timeSegmentList is large, as it will always be fetched from the database even if it’s not needed. Therefore, this solution is not recommended for large data sets. We are currently exploring more efficient solutions.
- Loading branch information