In my application, I have a domain layer and a service layer. The service layer needs to "serialize" the domain objects so they can be transmitted over the wire to consumer applications - in this case, serializing an object is just converting it to name value pairs. Because of this, I need to create Aggregate boundaries - this is CRITICAL - so serialization knows where objects start and stop. So, for instance, where everyone might have the following class:
Code:
public class Person
{
public string FirstName;
public Car PrimaryVehicle;
public Person Spouse;
}
I have the following class:
Code:
public class Person
{
public string FirstName;
public Reference<Car> PrimaryVehicle;
public Reference<Person> Spouse;
}
This way, I can reference the PrimaryVehicle like:
Code:
Person p = Repository.GetByGuid<Person>( personGuidToFetch );
Console.Write( p.PrimaryVehicle.Guid ); // GUID is returned
Console.Write (p.PrimaryVehicle.Name); // Name is returned
Console.Write(p.PrimaryVehicle.Object.Model); // the object is lazy loaded
I use the
Reference semantics ALL over the application and they are CRITICAL. I have a custom NHibernate type for
Reference so nHibernate knows how to persist it - it always ties to a
UNIQUEIDENTIFIER Sql column. So what I need to do is two things:
1. I need to be able to use JOIN semantics I want to run HQL like:
Code:
select p.* from Person p inner join Vehicle v where v.Model='Honda'
I need nHibernate to treat my
Reference like a regular object-to-object.
If this is going to take some modification of NHibernate (I assume it will), where's the best place to start?
AND
2. Need to autopopulate the name of the references when I bring up the main objectSo, when I run this HQL:
Code:
select p.* from Person p
I want to make nHIbernate run:
Code:
select p.FirstName, p.SpouseGuid, s.Name as Spouse_Name, p.PrimaryVehicleGuid, v.Name as PrimaryVehice_Name from Person p
left outer join Vehicles v on p.PrimaryVehicleGuid = v.Guid
left outer join Person s on p.SpouseGuid=s.Guid
And then I want my custom NHibernate type to be able to take PrimaryVehicle_Name and Spouse_Name and place them in the
Reference properties for the Person that was just fetched.
If this is going to take some modification of NHibernate, where's the best place to start?
Thanks!
Andrew