Hi guys,
I have a small project and I need your help with NHibernate, I read the manual many times but I didn't find a solution...or at least I didn't manage to find an elegant one.
I've a web service I can't modify to retrieve and store records from a remote location.
I have to first map the remote DB locally and after a separate software will create new records in the local DB that I have to push back with the webservice.
In other words I have to keep the local and the live DBs in synch with the possibility to create/update/delete records on both sides.
The problem is more or less the following:
Web service objects are linked to each other, but instead of an object having a reference of another object it has a reference to a RecordRef object. Using the RecordRef object it's then possible to retrieve the linked object.
For example:
Class Employee
{
public string name
public RecordRef employeeStatus
public RecordRef employeeDepartment
}
Class RecordRef
{
public int id
public string linkedTableName (this will be 'EmployeeStatus' or 'EmployeeDepartment' in the example)
}
Class EmployeeStatus
{
public int employeeStatusId
public string status
}
Class EmployeeDepartment
{
public int employeeDepartmentId
public string department
}
In practice instead of linking the Employee directly to EmployeeStatus and EmployeeDepartment they link it to the RecordRef.
I don't think it's complex to map all this to a DB using NHibernate (more or less I managed to do it).
But the problem is that I want to 'hide' the further RecordRef step in the DB. I would like to link Employee directly to EmployeeStatus in the DB (so that the other software can easily create records) using both the 'id' and the 'linkedTableName' and when I retrieve one of them back I would like to create a RecordRef on the fly (so I can push the object to the web service).
I thought to use my own "Access Strategy" or event "Interceptor" but maybe there is a simpler way.
Thanks for your suggestions,
Raffaele
|