Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
izzat5233 committed May 20, 2023
1 parent 6cde5f4 commit cd2fcc1
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions ccsm-core/src/main/java/stu/najah/se/core/dao/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,4 @@ static Session createSession() throws HibernateException {
return sessionFactory.openSession();
}

/**
* Executes the given SessionUsage functional interface within a try-with-resources block,
* ensuring the session is properly closed after the operation.
*
* @param usage The SessionUsage functional interface to be executed with the session
* @param <T> The type of the result returned from the session operation
* @return The result of the session operation
*/
static <T> T useSession(SessionUsage<T> usage) {
try (var session = sessionFactory.openSession()) {
return usage.perform(session);
}
}

/**
* A functional interface to be used with the useSession method.
* Provides an abstract perform method to execute operations on the session.
*
* @param <T> The type of the result returned from the session operation
*/
@FunctionalInterface
interface SessionUsage<T> {
T perform(Session session);
}
}

0 comments on commit cd2fcc1

Please sign in to comment.