Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Composite Key OneToOne Join
Composite Key OneToOne Join [message #841617] Wed, 11 April 2012 14:54 Go to next message
X Y is currently offline X YFriend
Messages: 3
Registered: April 2012
Junior Member
No Message Body

[Updated on: Sat, 02 December 2023 01:19]

Report message to a moderator

Re: Composite Key OneToOne Join [message #841652 is a reply to message #841617] Wed, 11 April 2012 15:37 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Remove the @JoinTable, you don't have one, this is not common in a OneToOne, normally just a @JoinColumn is used.

Try,
@JoinColumns({
@JoinColumn(name = "account_col1", referencedColumnName = "sup_col1"),
@JoinColumn(name = "account_col2", referencedColumnName = "sup_col2") })


James : Wiki : Book : Blog : Twitter
Re: Composite Key OneToOne Join [message #842269 is a reply to message #841652] Thu, 12 April 2012 06:19 Go to previous messageGo to next message
X Y is currently offline X YFriend
Messages: 3
Registered: April 2012
Junior Member
No Message Body

[Updated on: Sat, 02 December 2023 01:19]

Report message to a moderator

Re: Composite Key OneToOne Join [message #842373 is a reply to message #842269] Thu, 12 April 2012 08:31 Go to previous messageGo to next message
X Y is currently offline X YFriend
Messages: 3
Registered: April 2012
Junior Member
No Message Body

[Updated on: Sat, 02 December 2023 01:20]

Report message to a moderator

Re: Composite Key OneToOne Join [message #846652 is a reply to message #842373] Mon, 16 April 2012 14:17 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Your Supplier has a OneToMany to Account, so there are many accounts for a Supplier.
You are querying all Suppliers who have "any" account with division='Something', so you will get these back.

The accounts of a Supplier are always the same for that Supplier object, it does not matter how you queried it. You cannot change an object just by a query.

Perhaps use,

SELECT s, a FROM Supplier s
JOIN s.account a 
WHERE s.pk.accountNumber = 1 
AND (s.stat = '20' OR s.stat= '90') 
AND a.pk.division='Something'


This will give you back Suppliers and Accounts.


James : Wiki : Book : Blog : Twitter
Previous Topic:Persisting new entity or changing an entity
Next Topic:Default Allocation size for sequence
Goto Forum:
  


Current Time: Wed Apr 24 16:53:52 GMT 2024

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

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

Back to the top