In my jsp file I want to use a formbacking object. My problem is that the fields in my jsp file are connected to two different tables.
In the code below
productId, productName and productAddress are connected to table
Product through Product.hbm.xml.
ProductPrice are connected to table UserProduct through UserProduct.hbm.xml
How can have one
commandobject for this form?
In the code below I'm using product, but that doesn't work...
product.jsp
Code:
<form:form method="post" commandName="product">
<table class="inputTable">
<tr>
<td><label >Navn:</label></td>
<td><form:input path="productName"/></td>
</tr>
<tr>
<td><label>Adresse:</label></td>
<td><form:input path="productAddress"/></td>
</tr>
<tr>
<td><label >Pris:</label></td>
<td><form:input path="productPrice"/></td>
</tr>
</form:form>
Product.hbm.xmlCode:
<hibernate-mapping>
<class name="db.Product" table="Product">
<id name="ProductID" type="long" column="ProductID">
<generator class="native"/>
</id>
<property name="productName" column="ProductName" type="string"/>
</class>
</hibernate-mapping>
UserProduct.hbm.xmlCode:
<hibernate-mapping>
<class name="db.UserProduct" table="UserProduct">
<id name="UserProductID" type="long" column="UserProductID">
<generator class="native"/>
</id>
<property name="Username" column="Username"/>
<property name="ProductID" column="ProductID"/>
<property name="Price" column="Price" type="string"/>
</class>
</hibernate-mapping>