Hey all - I'm new to hibernate and wanted to get some feedback from forum members that may have had a similar issue as myself. I have two tables listed below. I need to have some data in the orderStatusTable to be there as "constants" and also need to support the addition of new data by a user.
- Is there a preferred way to model this in hibernate?
- Ideally, I'd like to have some static constants in my entity class representing some of the default data loaded at deployment.
I would really be grateful to anyone who can provide me with some pointers on this.
Sample usage:
Code:
Order o = new Order();
o.setStatus(OrderStatus.NEW()); // static variable perhaps?
OrderStatus custom = new OrderStatus("my_custom_status");
o.setStatus(custom);
Table structure: orderTableCode:
orderId orderStatusId
-----------------------------------------
1 1000
2 1001
orderStatusTableCode:
orderStatusId orderStatusDescription
-----------------------------------------------------------------
1000 NEW_ORDER
1001 COMPLETE_ORDER
1002 CUSTOM_STATUS