2013-03-22 55 views
0

簡單的查找表我堅持我的hibenate映射以下類Hibernate映射 - 使用性質爲重點

public class Order { 
    private String orderNumber; 
    private List<Component> Components = new ArrayList<Component>(); 
} 

public class Component{ 
    private String orderNumber; 
    private String partNumber; 
    private Integer rowNum; 
    private Part product; 
} 

public class Part{ 
    private String partNumber; 
    private String barcodeNumber 
    private Barcode barcode; 
} 
public class Barcode { 
    private String barcodeNumber; 
    private String itemBarcode; 
    private String boxBarcode; 
} 

Hibernate映射

ORDER

<class name="Order" table="Order" node="order" lazy="true"> 
    <id name="partNumber" unsaved-value="undefined" node="@partNumber"> 
     <column name="partNumber" not-null="true" /> 
    </id> 
    <bag name="Components" lazy="true" outer-join="false" fetch="select"> 
     <key column="_PARENT" /> 
     <one-to-many class="Component" /> 
    </bag> 
</class> 

COMPONENT

<class name="Component" table="component" node="order" lazy="true"> 
    <composite-id unsaved-value="undefined"> 
     <key-property name="enumber"> 
      <column name="_PARENT" not-null="true" /> 
    </key-property> 
    <key-property name="rowNum" > 
     <column name="_ROWNUM" not-null="true" /> 
    </key-property> 
     <key-property name="rpn" > 
      <column name="RPN" not-null="true" /> 
     </key-property> 
    </composite-id> 
    <property name="partNumber" node="@partNumber"> 
     <column name="partNumber" /> 
    </property> 
    <many-to-one lazy="proxy" fetch="join" update="false" insert="false" name="part" class="Part" column="partNumber" node="part" embed-xml="true"></many-to-one> 
</class> 

PART

<class name="Part" table="Part" node="part" lazy="true"> 
    <meta attribute="implement-equals">true</meta> 
    <cache usage="read-only"/> 
    <id name="cpn" type="string" unsaved-value="undefined" node="@cpn"> 
     <column name="CPN" not-null="true" /> 
    </id>  
    <property name="barcodeNumber" type="string" node="@barcodeNumber"> 
     <column name="barcodeNumber" not-null="false" /> 
    </property> 
    <many-to-one name="Barcode" foreign-key="barcodeNumber" class="Barcode" fetch="select"/> 
</class> 

BARCODE

<class name="Barcode" table="Barcode" node="barcode" lazy="true"> 
    <id name="barcodeNumber" unsaved-value="undefined" node="@barcodeNumber"> 
     <column name="barcodeNumber" not-null="true" /> 
    </id> 
    <property name="itemBarcode" type="string" node="@itemBarcode"> 
     <column name="itemBarcode" /> 
    </property> 
    <property name="boxBarcode" type="string" node="@boxBarcode"> 
     <column name="boxBarcode" /> 
    </property> 
</class> 

我遇到的問題是零件和條形碼類 的部分具有條形碼鏈接到部分 我無法改變一個特殊barcodeNumber數據結構但希望將這些表加在一起,以便我可以顯示帶有組件和零件以及條形碼的訂單列表

該映射傳遞初始加載但在檢索列出系統出現故障 org.hibernate.PropertyAccessException:拋出:IllegalArgumentException發生調用Barcode.barcodeNumber

的吸氣

回答

0

你必須添加getter和setter.Change代碼

FROM

private Barcode barcode; 

TO

private Barcode barcode = new Barcode(); 
+0

感謝這個做的工作:) – thefearlessdog 2013-03-24 23:08:17

0

正是憑着barcodeNumber

getter方法問題itSholudBe

getBarcodeNumber();