question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

asynchronous requests

See original GitHub issue

Good morning,

this is my Repository:

`[Transaction(ReadOnly = true)] public abstract class EntityRepository<T, K> : IEntityRepository<T, K> where T : Entity<K> { [Autowired] public ISessionFactory SessionFactory { protected get; set; }

    protected ISession CurrentSession
    {
        get
        {
            return SessionFactory.GetCurrentSession();
        }
    }

    public FlushMode FlushMode
    {
        get
        {
            return CurrentSession.FlushMode;
        }
        set
        {
            CurrentSession.FlushMode = value;
        }
    }

    public K Save(T entity)
    {
        return (K)CurrentSession.Save(entity);
    }

    public async Task<K> SaveAsync(T entity)
    {
        return (K)await CurrentSession.SaveAsync(entity);
    }

    public void Save(IEnumerable<T> entities)
    {
        foreach (T entity in entities)
        {
            CurrentSession.Save(entity);
        }
    }

    public T Get(K id)
    {
        return CurrentSession.Get<T>(id);
    }

    public async Task<T> GetAsync(K id)
    {
        using (var session = SessionFactory.OpenSession())
        {
            return await session.GetAsync<T>(id);
        }
    }

    public IQueryable<T> GetAllQueryable()
    {
        return CurrentSession.Query<T>();
    }`

and to make asynchronous requests I have to create a new session: using (var session = SessionFactory.OpenSession()) { return await session.GetAsync<T>(id); }

@lahma how can I configure nhibernate and spring to use the current session in asynchronous requests?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

1reaction
lahmacommented, Jun 11, 2020

I personally would be more than willing to review a pull request for that 😉

0reactions
lahmacommented, Oct 15, 2022

I’m doing a rude experiment with closing this, like what stale bot does, but maybe more human as I will probably actually react to feedback. As this issue has been stale for so long, I’ll close it. If it’s still an issue you would like to pursue, we can definitely reopen.

With limited resources this is just something that we need to do. Thank you for your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Synchronous and asynchronous requests - Web APIs | MDN
Asynchronous request. If you use an asynchronous XMLHttpRequest , you receive a callback when the data has been received. This lets the browser ......
Read more >
webserver - What is the difference between asynchronous ...
Asynchronous communication is when there could be multiple requests and responses could return in random order. – Logman. May 31, 2017 at 11:36....
Read more >
Difference between synchronous and asynchronous ...
Asynchronous Request : The Asynchronous request will not prevent the DOM or browser from executing additional code until the server responds. The ...
Read more >
Asynchronous Requests
Asynchronous request processing lets applications exit the Filter-Servlet chain but leave the response open for further processing. The Spring MVC ...
Read more >
How to Make 2500 HTTP Requests in 2 Seconds with Async ...
This is a comparison about how to use Async and Asynio with AIOHttp and Python vs using threads and concurrent futures to best...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found