I'm using the standard relational database design of using columns with either a integer or a char code of some sort which links to a reference table that has descriptions of the code. Basically, I want to display the meaningful name/description to the user but use the code behind the scenes (again, standard relational stuff).
How do I map this simple join?
When I use the <join> style below, I get an ORA-01722: invalid number because Hibernate is trying to join PORT_ID [char(4)] with PGM_ID [number(4)]. So, meanwhile, I'm using formula which doesn't seem efficient.
Please help since I have a bunch of these sort of join/lookups. Thanks in advance.
Code:
<hibernate-mapping>
<class name="DefaultPortfolio" table="DEFAULT_PORTFOLIO">
<id name="portfolioId" column="PORT_ID">
<generator class="assigned"/>
</id>
<property name="originatingSystemId" column="ORGG_SYS_ID"/>
<property name="programTypeId" column="PGM_ID"/>
<property name="programLongName"
formula="(select DISTINCT pr.PGM_LONG_NME from PROGRAM_REF pr where pr.PGM_ID=PGM_ID)"/>
<!-- Commented out since it results in a ORA-01722 error -->
<join table="PROGRAM_REF" inverse="true">
<key column="PGM_ID" />
<property name="programLongName" column="PGM_LONG_NME" />
</join>
-->
</class>
</hibernate-mapping>