Skip to content
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

Session should support oneShot operation #45

Open
CraigLRussell opened this issue Nov 24, 2016 · 4 comments
Open

Session should support oneShot operation #45

CraigLRussell opened this issue Nov 24, 2016 · 4 comments
Assignees

Comments

@CraigLRussell
Copy link
Contributor

In order to clean up resources associated with a Session, the Session must be closed. Some applications will perform just one action and regardless of the outcome, clean up the Session.

With either the callback model or promises model, there is extra work to do to close the Session.

This proposal adds a function to Session. Session.oneShot() will set the Session into a mode where it will be closed after executing a single function. When the promise is fulfilled or the callback is called, the Session is no longer usable.

@CraigLRussell CraigLRussell self-assigned this Nov 24, 2016
@jdduncan
Copy link
Contributor

Some thoughts:
What is the return from oneShot()?
What if a transaction is currently open?
In oneShot, Is it possible to create a batch and execute it?

@CraigLRussell
Copy link
Contributor Author

How about:
oneShot() returns the session so it can be chained. session.oneShot().find(...)
if a transaction is open, the next operation commits if successful and rolls back if not, then closes.
createBatch() does not trigger the behavior, but batch.execute() will close the session afterward.

@jdduncan
Copy link
Contributor

Same for createQuery() and query.execute(), yes?

@CraigLRussell
Copy link
Contributor Author

Same for createQuery() and query.execute(), yes?
Good catch. Yes. createQuery() would not trigger the behavior but query.execute() would execute and then close the session.

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

No branches or pull requests

2 participants