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 07:40 Go to next message
Sven Hoffmann is currently offline Sven Hoffmann
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 10:00 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
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 07:41 Go to previous message
Sven Hoffmann is currently offline Sven Hoffmann
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: Fri Aug 29 08:12:06 EDT 2014

Powered by FUDForum. Page generated in 0.01675 seconds