Hi,
I am a newbie for the hibernate and the OR mapping, and currently i am having a problem with mapping the Table to the Object.
We are having a scenario, where we store the Type and the Date (Key, Value) pair in the table, with the designed table structure and i wanted to know how this can be mapped with the Hibernate?
i gone thru many mapping documents and the code samples, and i came out withthe Composite Key option, one and the other is the Set mappings.
But i am having problem with both the stuffs and if any one have solved the issue earlier, it would be much more helpful in my case.
Let me give some sample here,
Though this is not the exact thing, i am trying to show the problem with this example,
Take case of Auditing function, i want to store the Type of action takes place, by what means the action taken place and the object on which the action takes place.
Consider the table structure is,
AuditId int (PK)
ActionType varchar(100)
ActionUserType varchar(10)
ActionBy int(10)
ObjectType varchar(10)
ObjectId int(10)
ActionUserType - This field will hold 'System' or 'User' value. where as , if the user makes the action, this will be 'User' and if it happens because of any System operations, this will have the value 'System'.
ActionBy - this will hold the id of the user whom made the action, incase if the ActionUserType is User, otherwise 0 to it.
Sameway, ObjectType, will hold the type of object on which the action is happened and ObjectId is the id of that object. For example, in a discussion forum, i can have either topics or messages. So i want to differentiate, Topic actions and message actions. So this will do.
Hope, this example could have explained the scenario and the problem and i would like to know how this can be solved using the mappings.
Thanks & Regards,
Deiva
|