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: Hibernate BatchSize not fetching batch
PostPosted: Thu Oct 02, 2008 3:36 pm 
Newbie

Joined: Fri Jan 04, 2008 4:21 pm
Posts: 4
I have the following relationship:

Code:
@Entity
public class Realm
{
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "realm")
  @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
  @BatchSize(size=100)
  public Set<Component> getComponents()
  {
    return components;
  }
}

@Entity
public class Component
{
  @ManyToOne(fetch = FetchType.LAZY)
  @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
  @JoinColumn(name = "ownerguid", referencedColumnName="guid", nullable = false,updatable=false,insertable=false)
  public Realm getRealm()
  {
    return realm;
  }
}


Then in my code I do this:

Code:
Set<Component> components = realm.getComponents();
for (Component component : components ) {
  if (name.equals(components.getName())) {
    System.out.println( "FOUND!" );
  }
}


The problem is, that when I call getComponents() and iterate over the set, I want it to pull up to 100 components at a time, instead of selecting each component. When I turned on show_sql=true, I can see that it is not doing the batch pull, I get a ton of selects for the components. I have tried using FetchMode.SUBSELECT as well, and FetchMode.JOIN, and neither of them work differently either. I still get each Component getting loading individually.

Is there some problem with this type of mapping that prevents the Batch select??

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.3.1

Name and version of the database you are using: Postgres 8.2.4


Top
 Profile  
 
 Post subject: Issue resolved
PostPosted: Fri Oct 03, 2008 2:51 pm 
Newbie

Joined: Fri Jan 04, 2008 4:21 pm
Posts: 4
The problem above was user error. Please disregard ! :(


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.