I am having trouble mapping a one to many relationship. I have doubled checked everything with the samples and I can't see what is wrong. It looks ok to me.
The exception is:
11:14:46,932 ERROR BasicPropertyAccessor:60 - IllegalArgumentException in class:
au.com.company.app.common.model.StoreTransaction, setter method
of property: stockNumber
11:14:46,932 ERROR BasicPropertyAccessor:64 - expected type: java.lang.String, a
ctual value: au.com.company.app.common.model.StoreMaster
Hibernate ExceptionIllegalArgumentException occurred while calling setter of au.
com.company.app.common.model.StoreTransaction.stockNumber
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="au.com.company.app.common.model.StoreMaster" table="store_master">
<id name="stockNumber" column="stock_number" type="java.lang.String" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="description" column="description"/>
<property name="locations" column="locations"/>
<property name="groupDescription" column="group_description"/>
<property name="crossReference" column="cross_reference"/>
<property name="otherDescription" column="other_description"/>
<property name="classField" column="class"/>
<property name="status" column="status"/>
<property name="unitOfIssue" column="unit_of_issue"/>
<property name="category" column="category"/>
<property name="supplierPartNo" column="supplier_part_no"/>
<property name="averagePrice" column="average_price"/>
<property name="lastBuyPrice" column="last_buy_price"/>
<property name="totalQuantity" column="total_quantity"/>
<property name="stockValue" column="stock_value"/>
<set name="transactions" cascade="all" inverse="true" lazy="true">
<key column="stock_number"/>
<one-to-many class="au.com.countryenergy.legacyarchive.common.model.StoreTransaction"/>
</set>
</class>
<class name="au.com.company.app.common.model.StoreTransaction" table="store_transaction">
<id name="uniqueKey" column="unique_key" type="java.lang.Long" unsaved-value="null">
<generator class="hilo"/>
</id>
<many-to-one name="stockNumber" class="au.com.company.app.common.model.StoreMaster" column="stock_number"/>
<property name="description" column="description"/>
<property name="location" column="location"/>
<property name="tranDate" column="tran_date"/>
<property name="tranNumber" column="tran_number"/>
<property name="lineNumber" column="line_number"/>
<property name="tranType" column="tran_type"/>
<property name="recOrdNumber" column="rec_ord_number"/>
<property name="qtyOrdered" column="qty_ordered"/>
<property name="qtyDelivered" column="qty_delivered"/>
<property name="price" column="price"/>
<property name="costCentre" column="cost_centre"/>
<property name="accountNumber" column="account_number"/>
<property name="tranReference" column="tran_reference"/>
</class>
</hibernate-mapping>
public class StoreMaster {
private String stockNumber;
private String description;
private String locations;
private String groupDescription;
private String crossReference;
private String otherDescription;
private String classField;
private String status;
private String unitOfIssue;
private String category;
private String supplierPartNo;
private Float averagePrice;
private Float lastBuyPrice;
private Float totalQuantity;
private Float stockValue;
private Set transactions;
...........
public class StoreTransaction {
private Long uniqueKey;
private String stockNumber;
private String description;
private String location;
private Date tranDate;
private String tranNumber;
private Long lineNumber;
private String tranType;
private String recOrdNumber;
private Float qtyOrdered;
private Float qtyDelivered;
private Float price;
private String costCentre;
private String accountNumber;
private String tranReference;
.............
Rgds,
Jeff.
|