-->
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 fetching with Criteria forces serveral selects
PostPosted: Fri Feb 11, 2011 10:10 am 
Newbie

Joined: Fri Feb 11, 2011 9:37 am
Posts: 1
Hi,

the code:

class Bid:
Code:
@Column(name = "something")
private String something;

@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
@JoinColumn(name = "bid_item_id")
private Item item;


class Item:
Code:
@OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "item")
private final Set<Bid> bids = new HashSet<Bid>();


The Criteria Query:

Code:
session.createCriteria(Item.class).createAlias("bids","b").add(Restrictions.eq("b.something", "value")).setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY).list();


Both classes are entities.

The problem is, that several queries are excuted/logged. One query for searching the items.
I think the other queries initialize the bid collections i think.

The result contains the right entities, but it runs slow.

Best regards

Dennis


Top
 Profile  
 
 Post subject: Re: Eager fetching with Criteria forces serveral selects
PostPosted: Fri Feb 11, 2011 8:30 pm 
Newbie

Joined: Wed Jan 26, 2011 12:32 pm
Posts: 12
Could you post rest of the code of your entities . I want to see get set methods


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.