7 Replies Latest reply on Mar 31, 2005 10:28 AM by bill.burke

    autocommit on cmp

    guurk

      I'm trying to get my brain over the FlushMode annotation.

      If I set the annotation to:

      @FlushMode ( value = FlushModeType.AUTO)
      


      Isn't this supposed to behave like the old autocommit features?

      Right now I must still merge modified entities via the entity manager before another query to the same bean will see modifications. Even with FlushMode set to AUTO.

      I'm I totaly missing the boat?


        • 1. Re: autocommit on cmp
          guurk

          Ok, so I'm reading a little bit more through the spec sheets.

          My entities are becoming detached since I'm getting them via a query and outside a transaction context.

          So now I just have to figure out how to get managed entities if I have to look them up via a non PK field.

          • 2. Possible Bug?
            guurk

            One more thing.

            I notice in my tests that there seems to be a bug.

            You can get a detached instance and then call persist with it on the entitymanager.

            Based on the spec it's supposed to throw an IllegalArgumentException. Instead it created a new managed instance.

            • 3. Re: autocommit on cmp
              bill.burke

              You reattached via the merge() or refresh() methods.

              • 4. Re: autocommit on cmp
                bill.burke

                FYI flush mode pertains to database synchronization, not transaction commit. Look at section 4.4.1 of the Persistence spec for more detail.

                • 5. Re: autocommit on cmp
                  bill.burke

                  FYI flush mode pertains to database synchronization, not transaction commit. Look at section 4.4.1 of the Persistence spec for more detail.

                  • 6. Re: autocommit on cmp
                    guurk

                    Deal, my fault for confusing the issue b/t commit and synch.

                    Truly I'd rather not have to deal with either in my current application. When a change is made on the entity I want it immediatly reflected in the database, and viceversa.

                    So, no transactions and immediate synchronization.

                    • 7. Re: autocommit on cmp
                      bill.burke

                      sorry, you can only reattach with merge(). Refresh() requires a managed object.