-->
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.  [ 1 post ] 
Author Message
 Post subject: N+1 Queries in FetchMode.JOIN if association does not exist
PostPosted: Tue Aug 25, 2015 1:36 pm 
Newbie

Joined: Tue Aug 25, 2015 1:27 pm
Posts: 1
I have a similar kind of association and
1.I use Criteria Restrictions to get all SideBlue's
2.There are 2000 SideBlues but about 750 SideBlue's does not have a SideRed.
When i try to get all SideBlue's the below queries get fired
1.A single LEFT OUTER JOIN query that fetches both SideBlue and SideRed using a Join
2.And then 750 queries using TwoPhaseLoad algorithm to get all SideRed's (though they do not exist as it is NULL)

@Entity
class SideBlue {
@Column(nullable = false)
private Integer timestamp;

@OneToOne(optional=true)
@JoinColumn(name="timestamp", referenceColumn="timestamp", insertable = false, updatable = false)
@Fetch(FetchMode.JOIN)
SideRed redSide;
}
@Entity
class SideRed {
@Column(nullable = false)
private Integer timestamp;
}

How do I avoid those 750 Queries as they are NULL and I do not expect any records. I use PROGRESS JDBC driver and OpenEdge hibernate dialect.


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

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.