glassfish
  1. glassfish
  2. GLASSFISH-20968

find() method with EXTENDED Persistence Context and TX_TYPE: NOT_SUPPORTED

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.1
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Ubuntu 64bits, OpenJDK 7, JavaDB

      Description

      According to spec:

      "The find method (provided it is invoked without a lock or invoked with LockModeType.NONE)
      and the getReference method are not required to be invoked within a transaction. If an entity man-
      ager with transaction-scoped persistence context is in use, the resulting entities will be detached; if an
      entity manager with an extended persistence context is used, they will be managed. See section 3.3 for
      entity manager use outside a transaction."

      That's is not properly working for GF4 (I have tested that with GF3 and works as expected):

      If I have a Gateway like this:

      @Stateful
      @TransactionAttribute(NOT_SUPPORTED)
      public class CustomerGateway {

      @PersistenceContext(unitName = "customersPU", type = EXTENDED)
      private EntityManager em;
      private Customer customer;

      public Customer find(Long id)

      { // customer is not managed! this.customer = em.find(Customer.class, id); // Prints false! System.out.println("Method find: " + em.contains(customer)); // Prints false too (2 is the id of an entity)! System.out.println("Method find: " + em.contains(em.find(Customer.class, 2L)); // A workaround customer = em.merge(customer); // Print true. System.out.println("Method find after merge: " + em.contains(customer)); return this.customer; }

      Is not working according to spec.

      I have create a GitHub project, maybe is useful for you:
      https://github.com/sdmoralesma/SO-21356448

        Activity

        Hide
        jclingan added a comment -

        If evaluation of this issue shows spec compliance issues, then this bug should be fixed.

        Show
        jclingan added a comment - If evaluation of this issue shows spec compliance issues, then this bug should be fixed.
        Hide
        Ed Bratt added a comment -

        This is marked Must Fix for 4.0.1. Please evaluate. Thank you.

        Show
        Ed Bratt added a comment - This is marked Must Fix for 4.0.1. Please evaluate. Thank you.
        Hide
        ethan.wang added a comment -

        Fixed by change 63399

        Show
        ethan.wang added a comment - Fixed by change 63399
        Hide
        pdudits added a comment -

        It looks that this is not entirely fixed. Making any query in extended persistence context will detach all entities. I'll file a new issue for that.

        Show
        pdudits added a comment - It looks that this is not entirely fixed. Making any query in extended persistence context will detach all entities. I'll file a new issue for that.
        Hide
        nabizamani added a comment -

        @pdudits you are absolutely right! This issue is still not fixed! When calling em.find(...) the result is not managed. At least in Glassfish 4.1.1 and I'm not very happy about this! Did you already open another issue for this? If not I will open one and mention it here.

        Show
        nabizamani added a comment - @pdudits you are absolutely right! This issue is still not fixed! When calling em.find(...) the result is not managed. At least in Glassfish 4.1.1 and I'm not very happy about this! Did you already open another issue for this? If not I will open one and mention it here.
        Hide
        pdudits added a comment -

        My pull request will fix that in next Payara release. I still wonder if the TCK is so weak with regard to extended persistence context, or glassfish 4 was only declared passing it.

        Show
        pdudits added a comment - My pull request will fix that in next Payara release. I still wonder if the TCK is so weak with regard to extended persistence context, or glassfish 4 was only declared passing it.
        Hide
        nabizamani added a comment -

        @pdudits Thanks for that! I totally agree with what you say, also because this is not the first issue of that kind (and the other are still open)! I have just opened another ticket here: https://java.net/jira/browse/GLASSFISH-21535

        To everyone: please not for the other ticket! I can't even believe that this issue is naked as "fixed" - this is wrong!

        Show
        nabizamani added a comment - @pdudits Thanks for that! I totally agree with what you say, also because this is not the first issue of that kind (and the other are still open)! I have just opened another ticket here: https://java.net/jira/browse/GLASSFISH-21535 To everyone: please not for the other ticket! I can't even believe that this issue is naked as "fixed" - this is wrong!

          People

          • Assignee:
            ethan.wang
            Reporter:
            sdmoralesma
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: