 |
Castle Project Support forum
|
| View previous topic :: View next topic |
| Author |
Message |
mattyr
Joined: 01 May 2007 Posts: 4 Location: California
|
Posted: Wed May 02, 2007 5:07 am Post subject: Incorporating NHibernate's subselect fetching strategy |
|
|
This may be more of a "wishlist" post, but I'm curious if anyone has though about this, or has a better approach for the goal I have in mind.
I'm converting an existing data layer to ActiveRecord. Before the conversion, we used multiple SQL select statements to populate various tables in the local recordset with related data (Order->OrderItems, for example). We could customize the subselect queries based upon user customizable search criteria (OrderItem contains Product "foo"). These queries can potentially return thousands of objects (rows) of various types. Each of the individual tables are rather large, so as we've transitioned to ActiveRecord we're finding that using fetching strategies that result in joins are far too inefficient to be effective. We'd also like to preload as many of the objects as possible, as cascading select statements for each item is also proving to perform poorly.
What I've found is that NHibernate (1.2) has incorporated a fetching strategy that closely replicates what we were doing using plain old ADO.NET. What I'm referring to is subselect, mentioned (albeit briefly) in the documentation here.
We're using activerecord built from trunk, and it does not appear to support this functionality. Does anyone know if there is a reason for this? I'm currently experimenting with the following changes in the trunk code:
\ActiveRecord\Castle.ActiveRecord\Attributes\Enums.cs (~ line 107):
| Code: |
/// <summary>
/// Define the possible fetch option values
/// </summary>
public enum FetchEnum
{
/// <summary>
/// Let NHibernate decide what to do here
/// </summary>
Unspecified,
/// <summary>
/// Use a JOIN to load the data
/// </summary>
Join,
/// <summary>
/// Use a seperate SELECT statement to load the data
/// </summary>
Select,
// This is the new part:
SubSelect
}
|
and, in \ActiveRecord\Castle.ActiveRecord\Framework\Internal\Visitors\XmlGenerationVisitor.cs (~ line 952):
| Code: |
private static string TranslateFetch(FetchEnum fetch)
{
switch(fetch)
{
case FetchEnum.Select:
return "select";
case FetchEnum.Join:
return "join";
// This is the new part:
case FetchEnum.SubSelect:
return "subselect";
default:
return null;
}
}
|
I'm curious if this strategy will work... I'm ashamed to admit I have not yet run through all of the unit tests with this patch, but I did want to hear some opinions before I delve into this any further.
I'd like to see the subselect fetching strategy incorporated into ActiveRecord, but is there a better place for this tag? I realize that this can't apply in some places where the FetchEnum can be used (BelongsToAttribute, for example), but NHibernate will quickly throw an exception if it's out of place.
Any thoughts would help. Particularly complaints, or examples of situations where this would fail or produce unintended results. I'm completely open to alternative approaches as well.
Thanks! |
|
| Back to top |
|
 |
hammett Castle Team

Joined: 15 Apr 2006 Posts: 1739 Location: SP, Brasil
|
|
| Back to top |
|
 |
|
|
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 You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|