Forgetting for the moment that this has to be done at run time :)
I have a table “Client” with the following columns
Code:
ID integer - Identity column
FistContact integer - ID value of the first user who contacted the client
FirstContactDate Date -Date of the first contact with the client.
I which to map to the following class
Code:
Public class Client {
Private int ID;
Set field;
}
Where Fields will contain a list of all the custom fields. So I have an interface
Code:
Public ICustomField{
Private Object value;
}
and I create a class for each type of custom field.
My mapping looks like
Code:
<hibernate-mapping>
<class name="client " table="client " >
<id name="ID ">
…
</id >
<set name = "fields" >
This is where I have the problem. How do I add two elements, one for FirstContact and the second for FirstContactDate
</set>
</class>
</hibernate-mapping>
It would have been nice if the design had used a simple one to many table, but instead a pivot table was used!