Skip to content

Add operations to detect the current open session #1780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
noobgramming opened this issue Oct 26, 2023 · 2 comments · Fixed by #2231
Closed

Add operations to detect the current open session #1780

noobgramming opened this issue Oct 26, 2023 · 2 comments · Fixed by #2231
Milestone

Comments

@noobgramming
Copy link

Hello!
I'm writing some DAO-like code and want to ensure a Session is already open when it's called. But Hibernate Reactive doesn't expose a getCurrentSession() on SessionFactory

Mutiny SessionFactory already checks for this internally, but doesn't expose access

Mutiny Code:

		Mutiny.Session current = context.get( contextKeyForSession );
		if ( current != null && current.isOpen() ) {
			LOG.debug( "Reusing existing open Mutiny.Session which was found in the current Vert.x context" );
			return work.apply( current );
		}
		else {
			LOG.debug( "No existing open Mutiny.Session was found in the current Vert.x context: opening a new instance" );
			return withSession( openSession(), work, contextKeyForSession );
		}

Can we add something that allows you to fetch current session (if one is in progress), or at least check if a Session is already open?

@gavinking
Copy link
Member

You can just call withSession(). Please refer to the Javadoc:

		/**
		 * Perform work using a {@link Session reactive session}.
		 * <p>
		 * <il>
		 * <li>If there is already a session associated with the current
		 * reactive stream, then the work will be executed using that
		 * session.
		 * <li>Otherwise, if there is no session associated with the
		 * current stream, a new session will be created.
		 * </il>
		 * <p>

@DavideD DavideD added problem A limitation or source of discomfort and removed problem A limitation or source of discomfort labels Dec 6, 2024
gavinking added a commit to gavinking/hibernate-reactive that referenced this issue Apr 30, 2025
…om the context

this will make it easier to implement the necessary Quarkus integration
@DavideD DavideD changed the title Method for detecting if Session is open? Add operations to detect the current open session Apr 30, 2025
@DavideD DavideD added this to the 3.0.0.CR1 milestone Apr 30, 2025
gavinking added a commit to gavinking/hibernate-reactive that referenced this issue May 1, 2025
…om the context

this will make it easier to implement the necessary Quarkus integration
gavinking added a commit to gavinking/hibernate-reactive that referenced this issue May 1, 2025
…om the context

this will make it easier to implement the necessary Quarkus integration
gavinking added a commit that referenced this issue May 1, 2025
…ntext

this will make it easier to implement the necessary Quarkus integration
@gavinking
Copy link
Member

In the end I've added these, to make it easier to deal with reactive session management in Quarkus.

gavinking added a commit that referenced this issue May 1, 2025
…ntext

this will make it easier to implement the necessary Quarkus integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants