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