I have two tables, orders and orders_history with same table schema. Therefore, how should I create the value objects and hibernate mapping files for them actually?
As far as I understand, I should have to create TWO separate Java VO (with same fields on java class), e.g. order and orderHistory with hibernate mapping files like:
<hibernate-mapping default-lazy="false">
<class
name="com.test.vo.OrderVO"
table="ORDERS"
>
>
<hibernate-mapping default-lazy="false">
<class
name="com.test.vo.OrderHistoryVO"
table="ORDERS_HISTORY"
>
>
Then, if I have to copy the data from Orders table to OrderHistoryVO table
1. get collection of OrdersVO from Orders table (e.g. from OrdersVO)
2. loop them and then
- create OrdersHistoryVO
- set individual fields by get corresponding fields from OrdersVO
- can't use simple Object cast as two different type of objects
- quite troublesome
Thanks!
|