Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2258

OpenJPA is firing separate query for embedded class in the entity though annotted at @EagerFetchMode(FetchMode.JOIN)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.1.2
    • None
    • jpa
    • WebSphere Platform 8.0.0.2 [BASE 8.0.0.2 cf021148.03]
      Host Operating System is Windows XP, version 5.1
      Java version = 1.6.0, Java Compiler = j9jit26, Java VM name = IBM J9 VM
      Orb Version = IBM Java ORB build orb626-20111107.00

    Description

      I have a Embedded class in my entity which has some common similar columns for all the tables.

      e.g

      @Entity
      @Table(name = "MY_TABLE")
      public class MyTable implements Serializable {

      //... some specific fields here

      @Embedded
      @EagerFetchMode(FetchMode.JOIN)
      private CommonRowDetails commonRowDetails;

      //...getters and setter below
      }

      And the class CommonRowDetails contains some audit columns as

      @Embeddable
      public class CommonRowDetails implements Serializable {

      @Column(name = "ROW_ADD_STP", updatable = false)
      private Date rowAddStp;

      @Column(name = "ROW_ADD_USER_ID", updatable = false)
      private String rowAddUserId;

      @Column(name = "ROW_UPDATE_USER_ID")
      private String rowUpdateUserId;

      @Column(name = "ROW_UPDATE_STP")
      private Date rowUpdateStp;

      //...getters and setter below

      }

      All above columns are part of same table "MY_TABLE"
      So when I select the entity MyTable, I can see a separate query is getting executed for selecting (ROW_ADD_STP, ROW_ADD_USER_ID, ...) which is definitely not required. I also added the annotation @EagerFetchMode(FetchMode.JOIN) on field CommonRowDetails to select those with join/in same query.
      Please help me to know, how to avoid OpenJPA firing a separate query.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sandip.bhoi Sandip Bhoi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: