|
Re: Composite Key OneToOne Join [message #841652 is a reply to message #841617] |
Wed, 11 April 2012 15:37 |
|
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 #846652 is a reply to message #842373] |
Mon, 16 April 2012 14:17 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02939 seconds