Giter Site home page Giter Site logo

Comments (3)

zUniQueX avatar zUniQueX commented on May 27, 2024

Hi @irineuruiz. A change of the behavior would highly affect the current execution semantics.

At the moment, the UnitOfWorkApplicationListener opens a Session for the Jersey execution lifecycle and wraps a transaction around the execution of the resource method. If we would commit the transaction after the execution of the response filters, an exception thrown in the execution of a response filter would abort the whole transaction. But if you annotate a resource method with @UnitOfWork, you'd expect the transaction to commit, if no exception was thrown in the resource method.

The problem you're experiencing with the UnitOfWorkAwareProxyFactory is caused from the creation of the proxy class. This newly generated subclass doesn't inherit the @NameBinding annotation because it's not marked @Inherited. Therefore your annotation is not found on the proxied subclass and the name binding doesn't apply correctly.

I think the best you can do is to create a transaction yourself. The UnitOfWorkAspect commits the transaction after the execution of the resource method but doesn't close the Session. You can query it with ManagedSessionContext.currentSession() and then manually open a new transaction.

from dropwizard.

irineuruiz avatar irineuruiz commented on May 27, 2024

Thanks @zUniQueX

In fact, we solve it here by doing exactly that, we are opening a transaction and committing it.
I just thought it would be good to warn you because we didn't know that UnitOfWorkAwareProxyFactory would "break" the NameBinding functionality and our developers took a while to understand what was happening.

from dropwizard.

zUniQueX avatar zUniQueX commented on May 27, 2024

@irineuruiz That's a good hint. But I think theUnitOfWorkAwareProxyFactory isn't known so widely and other users will probably not deal with proxies themselves, if they can avoid it.

If you think this case has an impact to more users, documentation updates are greatly appreciated.

from dropwizard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.