I have an entity that uses an @EmbeddedId to identify the composite primary keys. in that entity I have a @ManyToOne relationship to another entity that also has an @EmbeddedId to hold the composite primary keys.
If I allow hibernate to alter the tables in my derby database it will successfully run two queries against my two entity tables and populate the objects when I run my Find method. (<prop key="hibernate.generate_ddl">false</prop>)
However when I do not allow hibernate to alter the tables (or when I work in a DB2 database where I do not have alter access the first query fails for obvious reasons. (the full query is below)
Hibernate is trying to select two columns that do not exist:
productser0_.poParent_PSCO_ID as pscoParent13_17_,
productser0_.poParent_PRPD_ID as pscoParent14_17_,
These two columns are representative of the @EmbeddedId for the entite that I have my @ManyToOne tag on.
How can I prevent hibernate from trying to query nonexistant columns? is it a config issue or do I need a mapping restriction?
Thanks,
Derek
select
productser0_.PO_ID as PSCO1_17_,
productser0_.PD_ID as PRPD2_17_,
productser0_.POH_TRNS_NO as PSCOH3_17_,
productser0_.PO_DS as PSCO4_17_,
productser0_.PO_EFFT_FR_DT as PSCO5_17_,
productser0_.PO_EFFT_TO_DT as PSCO6_17_,
productser0_.PO_EXTC_IN as PSCO7_17_,
productser0_.PO_IMPLN_DT as PSCO8_17_,
productser0_.PO_NM as PSCO9_17_,
productser0_.poParent_PSCO_ID as pscoParent13_17_,
productser0_.poParent_PRPD_ID as pscoParent14_17_,
productser0_.POH_RCD_MNTN_ID as PSCOH10_17_,
productser0_.POH_RCD_MNTN_TS as PSCOH11_17_,
productser0_.PO_STA_CD as PSCO12_17_
from
APP.PMT_CO_HIST productser0_
where
productser0_.PO_ID=? and productser0_.PD_ID=?
|