Thank Gavin, it really rock for the first case!!
Code:
<!-- This one-to-one relationship use 2 formula for each composite key of AddressBook. It mean that the first composite key (AddressType) == 'S' and the second (AddressKey) equal the branchCode column of the Branch Table -->
<one-to-one name="addressBook"
class="AddressBook">
<formula>'S'</formula>
<formula>branchCode</formula>
</one-to-one>
it generate a good SQL, and my test works!
Code:
select branch0_.branchCode as branchCode1_,
'C' as formula0_1_,
branch0_.branchCode as formula1_1_,
addressboo1_.addressType as addressT1_0_,
addressboo1_.addressKey as addressKey0_,
addressboo1_.streetFrench as streetFr3_5_0_ from as400_goodname.dbo.Branch branch0_
left outer join as400_goodname.dbo.AddressBook addressboo1_
on 'C'=addressboo1_.addressType
and branch0_.branchCode=addressboo1_.addressKey
where branch0_.branchCode=?
But I still have some problem with the second SQL generation:
Code:
<one-to-one name="addressBook" class="AddressBook">
<formula>'C'</formula>
<formula>(institution+transit+CONVERT(char(3), serviceCenter))</formula>
</one-to-one>
It doesn't generate the left outer join...: I also try with a simple formula and I still have problem with the join... The only difference between Branch and Composante is that a composante have a Composite-id (using a composite-id component as recommended)...
This is the wrong SQL:
Code:
select composante0_.institution as institut1_,
composante0_.transit as transit,
composante0_.serviceCenter as serviceC3_,
composante0_.composanteType as composan4_7_,
composante0_.paymentMode as paymentM5_7_,
'C' as formula0_,
composante0_.institution as formula1_
from as400_goodname.dbo.Composante composante0_
I dont see any reference to the Address table...
Thanks for helping me.
Etienne.