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.
|