-->
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.  [ 2 posts ] 
Author Message
 Post subject: Entitygraph and Hibernate Level 2 Cache
PostPosted: Tue Jan 10, 2017 11:02 pm 
Newbie

Joined: Tue Jan 10, 2017 10:58 pm
Posts: 1
I have a one-to-many relationship defined as below

Code:
@Cacheable
@Entity
@NamedEntityGraph(
    name = "Parent.Child",
    attributeNodes = {
        @NamedAttributeNode("children"),
    }
)
public class Parent {
    private Set<Child> children;
    // getter - setter
}

Now in my DAL, i'm calling this method

Code:
@Override
    public Defect getParentWithChildren(int id) {
        EntityGraph<?> graph = entityManager.getEntityGraph("Parent.Child");
        Map<String, Object> props = new HashMap<>();
        props.put("javax.persistence.fetchgraph", graph);
        return entityManager.find(Parent.class, id, props);
    }

Since i have loaded Parent with Children, i should be able to use children collection outside of the transaction. But i'm getting Lazyinitialization Exception. This happens only when hibernate level 2 cache - ehcache is enabled. If i disable it from config, it works as expected. Also if i initialize collection explicitly after find, it works as expected. So is it a bug?. I'm using Hibernate 5.2.6.Final with JPA 2.1.

EDIT: One more thing i noticed was that entity loads fine for the first time, so it must be sonethibg related with Entity Graph support.


Top
 Profile  
 
 Post subject: Re: Entitygraph and Hibernate Level 2 Cache
PostPosted: Wed Jan 11, 2017 3:53 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Looks like a bug to me. Please come up with a replicating test case and open a Jira issue. Thanks.


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

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.