In hopes that I can get a solution to my problem, I did some more
research with the NHibernate codebase.  The problem seems to be in
SingleTableEntityPersister.cs, line 543, DiscriminatorFilterFragment
(string alias) method which has this code:

                                string[] subclasses = SubclassClosure;
                                for (int i = 0; i < subclasses.Length; i++)
                                {
                                        IQueryable queryable = (IQueryable)
Factory.GetEntityPersister(subclasses[i]);
                                        if (!queryable.IsAbstract)
                                                
frag.AddValue(queryable.DiscriminatorSQLValue);
                                }
                                StringBuilder buf = new 
StringBuilder(50).Append(" and ").Append
(frag.ToFragmentString().ToString());

When trying to create the discriminator filter fragment ("IN (2, 3,
4)") for IActivity, the system only sees "Activity" as the subclass
(result of SubclassClosure).  Which is fine; I'd expect that if it
recursively added all discriminator values not only for subclasses but
for subclasses of subclasses.

Also, when I take the interface out of it, it seems to be ok with
inheritance at multiple levels.  The problem only occurs when I try to
make an interface the base type.

Finally, I saw that I made a mistake in my example here; Activity
should have been coded as abstract but wasn't.  The problem still
remains when I make this correction.

Is there something I need to do to provide more information beyond
this?

On Jun 25, 1:36 pm, Michael Hedgpeth <[email protected]> wrote:
> I have an issue with NHibernate giving me the following error:
>
> System.NotSupportedException: Attempting to parse a null value into an
> sql string (column:activity0_.Type).
> at NHibernate.SqlCommand.InFragment.ToFragmentString() in
> InFragment.cs: line 109
> at
> NHibernate.Persister.Entity.SingleTableEntityPersister.DiscriminatorFilterFragment
> (String alias) in SingleTableEntityPersister.cs: line 551
>
> I set up a simple solution to reproduce the error.  I have the
> following domain classes:
>
>     public interface IActivity
>     {
>         Guid Id { get; set; }
>     }
>
>     public class Activity : IActivity
>     {
>         public DateTime StartTime { get; set; }
>         public Guid Id { get; set; }
>     }
>
>     public class Running : Activity
>     {
>         public string Where { get; set; }
>     }
>
>     public class Talking : Activity
>     {
>         public string ToWhom { get; set; }
>     }
>
> And the following mapping xml:
>
> <?xml version="1.0" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
>                    assembly="NHibernateTesting"
>                    namespace="NHibernateTesting" >
>   <class name="IActivity"
>          lazy="false"
>          table="Activity"
>          discriminator-value="0"
>          abstract="true">
>     <id name="Id">
>       <generator class="guid" />
>     </id>
>     <discriminator column="Type" type="Int16" />
>     <subclass name="Activity"
>               discriminator-value="1"
>               abstract="true"
>               lazy="false">
>       <property name="StartTime" />
>     </subclass>
>     <subclass name="Running"
>               discriminator-value="2"
>               lazy="false"
>               extends="Activity">
>       <property name="Where" />
>     </subclass>
>     <subclass name="Talking"
>               discriminator-value="3"
>               lazy="false"
>               extends="Activity">
>       <property name="ToWhom" />
>     </subclass>
>   </class>
> </hibernate-mapping>
>
> Any idea what I am doing wrong?
>
> Thanks!
> Michael Hedgpeth
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to