-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: EntityGraph and SubGraph
PostPosted: Thu Aug 14, 2014 6:32 am 
Newbie

Joined: Thu Aug 14, 2014 6:22 am
Posts: 2
Hi,

I have two JPA entities that look like this:

Code:
@Entity
@Table
@NamedEntityGraphs(value = {
      @NamedEntityGraph(name = "User.findByLogin",
            attributeNodes = {
                  @NamedAttributeNode(value = "profile")})
})
public class User implements Serializable{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id = 0;
   
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    private Profile profile;

    // Getters and setters removed
}

@Entity
@Table
public class Profile implements Serializable{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id = 0;
   
    @Column
    private String name;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    private User lastModifier;

    // Getters and setters removed
}


When I a query one user with the entitygraph "User.findByLogin", the profile attribute is eagerly loaded as expected.
But my issue is that profile.lastModifier is also eagerly loaded.

Why is the Profile object fully loaded? Shouldn't it respect the default graph and then lazy load the lastModifier attribute?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.