Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » SecondaryTable causes invalid join (Bug)
SecondaryTable causes invalid join (Bug) [message #1391692] Tue, 01 July 2014 09:08 Go to next message
Omid Pourhadi is currently offline Omid PourhadiFriend
Messages: 13
Registered: May 2013
Junior Member
Hi,

I have a simple model as follow :

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Table(name = "cfs_document", uniqueConstraints = @UniqueConstraint(columnNames = { "uuid" }))
@SecondaryTable(name = "cfs_doc_access", pkJoinColumns = @PrimaryKeyJoinColumn(name = "doc_id", referencedColumnName = "id"))
@XmlRootElement
@ClassExtractor(value = DocumentClassExtractor.class)
// @Customizer(DocumentCustomizer.class)
public class Document extends DocumentVO
{
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parent_id", table = "cfs_doc_access")
    @JoinFetch(JoinFetchType.OUTER)    
    private Document parent;
}


after I run this query

select d from Document d where d.id in :ids and d.parent is not null


it produces this sql with 4 INNER JOIN of same tables how eclipselink do that?! which I assume is not correct

SELECT * FROM cfs_doc_access t3, 
  cfs_document t2, cfs_doc_access t1, cfs_document t0 WHERE ((((t2.id IN (?)) AND NOT ((t3.parent_id IS NULL))) 
  AND (t3.doc_id = t2.id)) AND ((t0.id = t3.parent_id) AND (t1.doc_id = t0.id)))


is this a bug ?
Re: SecondaryTable causes invalid join (Bug) [message #1395851 is a reply to message #1391692] Mon, 07 July 2014 13:43 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
The query shown seems to match what you have queried for. The query seems to be asking for t2+t3 rows, and has a join fetch on the parent relationship that brings in the t1+t0 rows. Since you have used d.parent in the query, the outer join is forced into an inner join since you are already restricting the results to only include documents with a parent.

Are the results incorrect?
Re: SecondaryTable causes invalid join (Bug) [message #1397086 is a reply to message #1395851] Wed, 09 July 2014 07:19 Go to previous message
Omid Pourhadi is currently offline Omid PourhadiFriend
Messages: 13
Registered: May 2013
Junior Member
results are correct although it's too slow. I was kind of hoping for this query

SELECT * FROM  cfs_document t0
LEFT OUTER JOIN cfs_doc_access t1 on 
t0.id = t1.doc_id
 WHERE ((((t0.id IN (?)) AND NOT ((t1.parent_id IS NULL))) 


anyway since there is no way to LEFT join secondary table I assume I expected too much Smile

thank you for your reply.

[Updated on: Wed, 09 July 2014 07:30]

Report message to a moderator

Previous Topic:JPQL passing binary enum instead of enum's ordinal as SQL param value for key in Map<enum, String
Next Topic:Hanging and long delays obtaining read locks
Goto Forum:
  


Current Time: Tue Mar 19 05:45:16 GMT 2024

Powered by FUDForum. Page generated in 0.02251 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top