Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.12.0
    • Component/s: camel-jpa
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Spring 3.1 deprecated JpaTemplate and JpaCallback in favor of directly acting upon JPA's EntityManager. Replace JpaTemplateTransactionStrategy and make other improvements.

        Issue Links

          Activity

          Hide
          Brett E. Meyer added a comment -

          Looks great, good catches. Thanks Claus!

          Show
          Brett E. Meyer added a comment - Looks great, good catches. Thanks Claus!
          Hide
          Claus Ibsen added a comment -

          Thanks Brett

          I managed to merge your work and complete the missing/failing test etc.

          Show
          Claus Ibsen added a comment - Thanks Brett I managed to merge your work and complete the missing/failing test etc.
          Hide
          Brett E. Meyer added a comment - - edited

          Hey Claus Ibsen, apologies again. Life has gotten away from us lately...

          I pushed the current state to https://github.com/brmeyer/camel/tree/CAMEL-5932. There are a couple of test failures that I still need to work through. If someone else has time to take a look, great. Otherwise, I'll see what I can do (although freetime has been diminishing).

          It replaces the use of Spring's JpaTemplate with direct usage of EntityManager within a TransactionTemplate.

          Admittedly, I'm not 100% on how Spring's JpaTemplate worked. However, based off of some of the unit tests and the original architecture of the consumer/producer, it appears that one EntityManager was opened and shared. Typically, it's best to use one EM per unit of work, rather than per request or global. However, in this context, the global context makes a bit of sense. It's left open and closed only on the endpoint's #doStop. Anyone disagree with that?

          One failure is JpaUsePersistTest#produceExistingEntityShouldThowAnException(). Even though debugging showed that JpaUsePersistTest#entityManager and JpaProducer#entityManager were the same instance (Spring's LocalEntityManagerFactoryBean returns the same EM instance for #createEntityManager() until the EM is explicitly closed, I believe), it's not throwing an exception anymore if the same entity is persisted twice. I'm not sure if that was something specific that the JpaTemplate was providing (and OpenJPA doesn't natively do what we expect) or if there's something else stupid that I'm missing.

          JpaProducerConcurrentTest is failing also, but I haven't had a chance to really dig into it.

          Show
          Brett E. Meyer added a comment - - edited Hey Claus Ibsen , apologies again. Life has gotten away from us lately... I pushed the current state to https://github.com/brmeyer/camel/tree/CAMEL-5932 . There are a couple of test failures that I still need to work through. If someone else has time to take a look, great. Otherwise, I'll see what I can do (although freetime has been diminishing). It replaces the use of Spring's JpaTemplate with direct usage of EntityManager within a TransactionTemplate. Admittedly, I'm not 100% on how Spring's JpaTemplate worked. However, based off of some of the unit tests and the original architecture of the consumer/producer, it appears that one EntityManager was opened and shared. Typically, it's best to use one EM per unit of work, rather than per request or global. However, in this context, the global context makes a bit of sense. It's left open and closed only on the endpoint's #doStop. Anyone disagree with that? One failure is JpaUsePersistTest#produceExistingEntityShouldThowAnException(). Even though debugging showed that JpaUsePersistTest#entityManager and JpaProducer#entityManager were the same instance (Spring's LocalEntityManagerFactoryBean returns the same EM instance for #createEntityManager() until the EM is explicitly closed, I believe), it's not throwing an exception anymore if the same entity is persisted twice. I'm not sure if that was something specific that the JpaTemplate was providing (and OpenJPA doesn't natively do what we expect) or if there's something else stupid that I'm missing. JpaProducerConcurrentTest is failing also, but I haven't had a chance to really dig into it.
          Hide
          Claus Ibsen added a comment -

          Any update on this? If you have a partial patch just attach the file. If you dont have time to work on it, that is fine too, then just let us know so maybe others can work on it, or we can push it for later.

          Show
          Claus Ibsen added a comment - Any update on this? If you have a partial patch just attach the file. If you dont have time to work on it, that is fine too, then just let us know so maybe others can work on it, or we can push it for later.
          Hide
          Brett E. Meyer added a comment -

          Sorry Claus, completely forgot about this. src is finished, but fixing up some test corrections. I'll have a pull request shortly.

          Show
          Brett E. Meyer added a comment - Sorry Claus, completely forgot about this. src is finished, but fixing up some test corrections. I'll have a pull request shortly.
          Hide
          Claus Ibsen added a comment -

          As Camel 2.12 dropped support for spring 3.0, we can now safely migrate.

          Brett any update on this?

          Show
          Claus Ibsen added a comment - As Camel 2.12 dropped support for spring 3.0, we can now safely migrate. Brett any update on this?
          Hide
          Brett E. Meyer added a comment -

          I'm working on it in my GitHub fork: https://github.com/brmeyer/camel/tree/CAMEL-5932

          Show
          Brett E. Meyer added a comment - I'm working on it in my GitHub fork: https://github.com/brmeyer/camel/tree/CAMEL-5932

            People

            • Assignee:
              Claus Ibsen
              Reporter:
              Brett E. Meyer
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development