title: Getting @Id of lazy-loaded @ManyToOne entity allways returns null
body: <p>I am using Hibernate 4.3.8.Final and have problem with retrieving @Id property of lazy fetched property: For attached classes calling <code>aidConfiguration.getChipApplication().getId()</code> allways returns <code>null</code>. Other properties, eg. <code>aidConfiguration.getChipApplication().getVersion()</code> returns correctly the value from DB. If <code>chipApplication</code> is not lazy loaded (see the comment in the code), then <code>aidConfiguration.getChipApplication().getId()</code> returns correct non-null value.</p>
  
  <p>What am I dong wrong?</p>
  
  <p>BTW I need it to be lazy.</p>
  
  <p>BaseEntity:</p>
  
  <pre><code>@MappedSuperclass
  public class BaseEntity implements Serializable {
  
      @Id
      @Column(name = "ID", unique = true)
      @Size(min = 1, max = 255)
      private String id;
  
      @PrePersist
      public final void generateUuid() {
          if (this.getId() == null) {
              this.setId(UUID.randomUUID().toString());
          }
      }
  
      public final String getId() {
          return id;
      }
  
      public final void setId(final String id) {
          this.id = id;
      }
  }
  </code></pre>
  
  <p>AidConfiguration:</p>
  
  <pre><code>@Entity
  @Audited
  public class AidConfiguration extends BaseEntity {
  
      @Column
      @NotBlank
      private String name;
  
      @NotNull
      @ManyToOne(fetch = FetchType.LAZY) // if it is EAGER (defaut) then then aidConfiguration.getChipApplication().getId() returns correctly non-null value
      private ChipApplication chipApplication;
  
      @OneToMany(fetch = FetchType.LAZY, mappedBy = "aidConfiguration", cascade = CascadeType.ALL) // cascade for auto-saving and deleting items
      private List&lt;AidConfigurationItem&gt; aidConfigurationItems;
  
      public String getName() {
          return name;
      }
  
      public void setName(final String name) {
          this.name = name;
      }
  
      public ChipApplication getChipApplication() {
          return chipApplication;
      }
  
      public void setChipApplication(final ChipApplication chipApplication) {
          this.chipApplication = chipApplication;
      }
  
      public List&lt;AidConfigurationItem&gt; getAidConfigurationItems() {
          return aidConfigurationItems;
      }
  
      public void setAidConfigurationItems(final List&lt;AidConfigurationItem&gt; aidConfigurationItems) {
          this.aidConfigurationItems = aidConfigurationItems;
      }
  }
  </code></pre>
  
  <p>ChipApplication:</p>
  
  <pre><code>@Entity
  @Audited
  public class ChipApplication extends BaseEntity {
  
      @Column
      @NotBlank(message = "Aid can not be empty")
      private String aid;
  
      @Column
      @NotBlank(message = "Product can not be empty")
      private String product;
  
      @Column
      @NotBlank(message = "Version can not be empty")
      private String version;
  
      @NotNull(message = "Network is mandatory")
      @ManyToOne(fetch = FetchType.LAZY)
      private Network network;
  
      @ManyToMany(fetch =  FetchType.EAGER)
      private List&lt;AidTag&gt; aidTags;
  
      public String getAid() {
          return aid;
      }
  
      public void setAid(final String aid) {
          this.aid = aid;
      }
  
      public String getProduct() {
          return product;
      }
  
      public void setProduct(final String product) {
          this.product = product;
      }
  
      public String getVersion() {
          return version;
      }
  
      public void setVersion(final String version) {
          this.version = version;
      }
  
      public Network getNetwork() {
          return network;
      }
  
      public void setNetwork(final Network network) {
          this.network = network;
      }
  
      public List&lt;AidTag&gt; getAidTags() {
          return aidTags;
      }
  
      public void setAidTags(final List&lt;AidTag&gt; aidTags) {
          this.aidTags = aidTags;
      }
  }
  </code></pre>