Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.3
Mapping documents:
<!-- InventoryTransDetailsInfo start-->
<class name="com.vertical.accelere.inventory.InventoryTransDetailsInfo" table="inventory_transaction_details">
<composite-id>
<key-property name="itemCode" column="item_code" type="int"/>
</composite-id>
<property name="price" column="price" type="double"/>
<property name="quantity" column="quantity" type="double"/>
<many-to-one name="itInfo" column="transaction_no" class="com.vertical.accelere.inventory.InventoryTransInfo"></many-to-one>
</class>
<!-- InventoryTransDetailsInfo end-->
<!-- InventoryTransactionInfo start-->
<class name="com.vertical.accelere.inventory.InventoryTransInfo" table="inventory_transaction">
<id name="transactionNumber" type="int" column="transaction_no">
<generator class="increment" />
</id>
<property name="transactionType" type="string" column="transaction_type"/>
<bag name="itdInfo" lazy="true" inverse="true" cascade="save-update" >
<key column="transaction_no"></key>
<one-to-many class="com.vertical.accelere.inventory.InventoryTransDetailsInfo"/>
</bag>
</class>
<!-- InventoryTransactionInfo end-->
Name and version of the database you are using:
PostgreSQL 8
The generated SQL (show_sql=true):
Hibernate: update inventory_transaction set transaction_type=? where transaction_no=?
Hibernate: update inventory_transaction_details set price=?, quantity=?, transaction_no=? where item_code=?
Hi
I have made one-to-many association between two table Inventory_transaction and Inventory_transaction_details tables.
Below is the generated SQL for Inventory_transaction_details table.
Hibernate: update inventory_transaction_details set price=?, quantity=?, transaction_no=? where item_code=?
But i want the query to be
Hibernate: update inventory_transaction_details set price=?, quantity=? where item_code=? and transaction_no=?
i.e i want item_code and transaction_no to be composite Primary key Inventory_transaction_details table.
How can i do that in the mapping file.
Help me friends.