Hello,
i'm trying to define a complex composite key szenario but i'm still getting errors.
situation:
1. table MASTERDATA ( xxx, yyy, zzz; pk (xxx,yyy) )
2. table USAGEDATA (aaa,bbb,xxx,yyy, tttt); pk(aaa,bbb,xxx,yyy))
with "virtual" foreignKey(xxx,yyy) references MASTERDATER.
the foreign key is "virtual" which means, that the key is not defined in the datebase. it's only present in the logical model. the fields USAGEDATA.xxx and USAGEDATA.yyy where primary and foreig key at once.
this is my attemt:
Code:
@Embeddable
public class MasterdataPk
{
String xxx;
String yyy;
}
@Entity
@Table(name="MASTERDATA")
public class Masterdata
{
@Id MasterdataPk id;
String zzz;
}
@Embeddable
public class UsageDataPk
{
Masterdata masterdata;
String aaa;
String bbb;
}
@Entity
@Table(name="USAGEDATA")
public class UsageData
{
@Id UsageDataPk id;
String ttt;
}
hibernate generates:
Code:
select ... a.masterdata_xxx, a. masterdata_yyy from USAGEDATA a ...
but i'm expecting a join like
Code:
select ... b.xxx, b._yyy from USAGEDATA a, MASTERDATA b where a.xxx = b.xxx and a.yyy = b.yyyy ...
i'm getting confused ;-)
thanks in advance