Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Join Query based on JoinTable with multiple joinColumns
Join Query based on JoinTable with multiple joinColumns [message #389413] Tue, 09 June 2009 11:40 Go to next message
Sven Hoffmann is currently offline Sven HoffmannFriend
Messages: 18
Registered: July 2009
Junior Member
Hi,

I'm using EclipseLink 1.1.1 to access a legacy database (AS400). In order
to map the OneToMany relation of the entity Order to a list of Container
entities a JoinTable with multiple joinColumns and inverseJoinColumns is
used as shown below.

@Entity
class Order {
...
@OneToMany
@JoinTable(name = "ORDERCONTAINER",
joinColumns = {
@JoinColumn(name = "ORDERT", referencedColumnName = "ORDERT"),
@JoinColumn(name = "ORDERN", referencedColumnName = "ORDERN") },
inverseJoinColumns = {
@JoinColumn(name = "CONTAINERP", referencedColumnName = "CONTAINERP"),
@JoinColumn(name = "CONTAINERO", referencedColumnName = "CONTAINERO")
})
private List<Container> containers;
...
}


When using an OUTER JOIN in a JPA Query or adding
@JoinFetch(JoinFetchType.OUTER) to the mapping of containers I found that
only on join column provided by the attribute joinColumns is taken into
account during SQL generation.


The SQL generated by JPA looks like:
SELECT ... FROM ORDER t1
LEFT OUTER JOIN
(ORDERCONTAINER t5
JOIN
CONTAINER t4
ON
(
(
t4.CONTAINERO = t5.CONTAINERO
)
AND
(
t4.CONTAINERP = t5.CONTAINERP
)
)
)
ON
(
t5.ORDERN = t1.ORDERN
)

"... AND t5.ORDERT= t1.ORDERT" is expected as a JOIN condition but missing.
Is this a known issue?

Thanks
Sven
Re: Join Query based on JoinTable with multiple joinColumns [message #389418 is a reply to message #389413] Tue, 09 June 2009 14:00 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This seems to be a bug, please log this issue.

The bug occurs for a ManyToMany with multiple join columns, the issue is
in the SQLSelectStatement method mapTableIndexToExpression(), as it
allowing only a single expression for each table. Also were the odd
spaces in the generated SQL, or did you add those?

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: Join Query based on JoinTable with multiple joinColumns [message #389437 is a reply to message #389418] Wed, 10 June 2009 11:41 Go to previous message
Sven Hoffmann is currently offline Sven HoffmannFriend
Messages: 18
Registered: July 2009
Junior Member
I reported bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=279784.

> Also were the odd spaces in the generated SQL, or did you add those?
I add those. The SQL was indented by me, but linebreaks were lost during
commit of the post.
Previous Topic:EclipseLink weaver agent or Spring agent
Next Topic:Trying to persist @Lob field throws NullPointerException
Goto Forum:
  


Current Time: Thu Apr 25 13:49:28 GMT 2024

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

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

Back to the top