-->
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: eager loading leads to unwanted recursion
PostPosted: Mon Mar 03, 2008 1:50 pm 
Newbie

Joined: Mon Mar 03, 2008 12:40 pm
Posts: 2
Hi,

I've used the composition pattern to define a virtual file system:

Code:
@Entity
public class VirtualFolder extends VirtualFile {

  @Composition
  @OneToMany(mappedBy="folder", cascade = CascadeType.ALL, fetch=FetchType.EAGER)
  private Set<VirtualFile> contents = new HashSet<VirtualFile>();


if I now load the root folder with

Code:
    session.createCriteria(VirtualRootFolder.class).uniqueResult();


I get the whole tree of all sub folders and sub sub sub folders.. but I only want one level, not all. If I remove the fetch annotation and define the fetch strategie in the criteria, I get the result I wanted:

Code:
    session.createCriteria(VirtualRootFolder.class).setFetchMode("contents", FetchMode.JOIN).uniqueResult();


Is there a way to define the same behaviour by annotations?

Best regards
Sebastian Baltes


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 08, 2008 12:33 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
nope

_________________
Emmanuel


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.