These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Using "JOIN" semantics in HQL with DDD-style Aggre
PostPosted: Wed Feb 18, 2009 11:46 am 
Newbie

Joined: Wed Feb 18, 2009 11:31 am
Posts: 3
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 object

So, 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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.