Hi, I am a newbie to Hibernate. Please help with below issue. We have two tables SALES(Sale_id,Producer,Product_Type) and PRODUCT_TYPE(Code,Description)
In the SALES table, the product code is stored. I would like to join the tables into one POJO class SALES which has (Sale_id,Producer,prod_Type,productTypeValue). Note - Code is a varchar. How can I do this ?
I tried this: <class name="com.sales.bo.SaleBO" table="SALES"> <id name="sale_Id" type="int"> <column name="SUBM_N"/> <generator class="identity"/> </id> <property name="prodcuer" type="java.lang.String"> <column name="Producer"/> </property> <property name="prod_type" type="java.lang.String"> <column name="Product_Type"/> </property>
<join table="PRODUCT_TYPE"> <key column="code"/> <property name="productTypeValue" type="java.lang.String" > <column name = "description" /> </property> </join> </class>
But got : [SQLServer]Conversion failed when converting the varchar value 'AAR' to data type int.
Later I added the "property-ref" attribute inside the <key> tag. But hibernate still queries on the primary key. Is there a workaround for this problem ?
|