-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: One to Many mapping
PostPosted: Wed Jan 28, 2004 8:35 pm 
Newbie

Joined: Tue Jan 06, 2004 12:57 am
Posts: 14
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 9:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
On the class StoreTransaction, you have defined a property named stockNumber of type String. Then in the mapping for StoreTransaction you try to define that property as an association.

So either map the StoreTransaction.stockNumber property as a String, or change the property's type to be StoreMaster...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.