Hi,
I have a Order class that contains a property called "statusId". The Order class also has a property called "status" that associates to another table which stores statusIds and corresponding status names.
On my jsp page, I display a bunch of orders and each order has a button that cancels the order. Also next to each order is the status name of the current status (for that order). When i click on cancel for a certain order, the order is cancelled and the action returns to the same page (with the updated status info for that order). But the status text does not change on first refresh. When I explicitly navigate to the page the status text changes.
I wrote a log statement to traverse through the orders in the action method before forwarding to the jsp and found that the "status" property of the order is not updated the first time. (the change is seen in the database and the statusId property has changed). When I refresh the db or navigate back to the page, the "status" property of order is updated and the status name changes.
I am not sure if I am clear in describing my problem, but basically hibernate does not update the "status" property immediately after the statusId is changed.
Hope someone can help me with this. My mapping files are shown below.
Thanks.
<hibernate-mapping package="com.myapp.model">
<class name="Order" table="shipping_order">
<id name="id" column="order_id" unsaved-value="0">
<generator class="native"/>
</id>
<many-to-one name="status"
class="com.myapp.model.OrderStatus"
column="status_id"
update="false"
insert="false"
lazy="false"
not-found="ignore"
/>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.myapp.model.OrderStatus" table="order_status">
<id name="id" column="status_id" unsaved-value="0">
<generator class="native"/>
</id>
<property name="name"/>
</class>
</hibernate-mapping>
|