I am trying to map a pretty simple master detail relationship, but now I am getting this exception:
javax.servlet.ServletException: net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: au.com.countryenergy.legacyarchive.common.model.CustomerHistory@e37e8a98, of class: au.com.countryenergy.legacyarchive.common.model.CustomerHistory
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
The master table (CustomerMaster) can have multiple child records (CustomerHistory). There is no primary key defined in CustomerHistory, so I decide to make all the fields part of the primary key (since the key is required?)
"No row with the given identifier exists" may mean that there is a customer number in CustomerHistory that does not exist in CustomerMaster?? (or something is null?)
What should I do to fix the mappings?
Thanks.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="au.com.countryenergy.legacyarchive.common.model.CustomerMaster" table="customer_master">
<id name="customerNumber" column="customer_number" type="java.lang.String">
<generator class="hilo"/>
</id>
<property name="searchKey" column="search_key"/>
<property name="customerName" column="customer_name"/>
<property name="firstNames" column="first_names"/>
<property name="customerAddress" column="customer_address"/>
<property name="customerType" column="customer_type"/>
<set name="history" cascade="all">
<key column="customer_number"/>
<one-to-many class="au.com.countryenergy.legacyarchive.common.model.CustomerHistory"/>
</set>
</class>
<class name="au.com.countryenergy.legacyarchive.common.model.CustomerHistory" table="customer_history">
<composite-id>
<key-property name="customerNumber" type="java.lang.String" column="customer_number"/>
<key-property name="serviceNumber" type="java.lang.String" column="service_number"/>
<key-property name="batchDate" type="java.sql.Date" column="batch_date"/>
<key-property name="tranDate" type="java.sql.Date" column="tran_date"/>
<key-property name="tranDetail" type="java.lang.String" column="tran_detail"/>
</composite-id>
</class>
</hibernate-mapping>
|