Sorry,

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="true"
assembly="RedBranch.LeagueFinder.Model"
namespace="RedBranch.LeagueFinder.Model">
  <class name="League" table="`League`" xmlns="urn:nhibernate-mapping-2.2">
    <cache usage="read-write" />
    <cache usage="read-write" />
    <id name="Id" column="Id" type="Guid">
      <generator class="guid" />
    </id>
    <!--Snip-->
    <joined-subclass name="RedBranch.LeagueFinder.Model.MlbLeague,
RedBranch.LeagueFinder.Model, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null">
      <key column="MlbLeagueId" />
      <property name="Id" type="Guid">
        <column name="Id" />
      </property>
      <!--Snip-->
    </joined-subclass>
      <joined-subclass name="RedBranch.LeagueFinder.Model.NflLeague,
RedBranch.LeagueFinder.Model, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null">
          <key column="NflLeagueId" />
          <property name="Id" type="Guid">
              <column name="Id" />
          </property>
          <!--Snip-->
      </joined-subclass>
  </class>
</hibernate-mapping>




 var criteria = Session.CreateCriteria(typeof(League))
                .Add(Expression.Eq("Id", id))
                .Add(Expression.In("State", new Enum[] { LeagueState.Live,
LeagueState.Closed, LeagueState.Open }));

return criteria.UniqueResult<League>();

On Wed, Mar 4, 2009 at 12:56 PM, Ayende Rahien <[email protected]> wrote:

> Please show the real mapping, and the NH query that you try to use.
>
>
> On Wed, Mar 4, 2009 at 10:03 AM, Scott Belchak <[email protected]> wrote:
>
>> I am stumped. I've been over this too many times and it's time for some
>> extra eyes on my problem.
>>
>> I'm using FluentNHibernate for my mappings.
>>
>> The problem that I am having is that when I am querying my League table
>> for a League that has a specified ID, the generated SQL tries to match the
>> ID up with a Sub Classes ID instead of the parent class.
>>
>> For instance.
>>
>> League
>> BaseballLeague : League
>> FootballLeague : League
>>
>> I get nothing back if I pass in an ID of a FootballLeague.
>>
>> (all of the mapping for the main class gets done in the
>> NamedDomainObjectMap)
>>
>> public class LeagueMap : NamedDomainObjectMap<League>
>>     {
>>         /// <summary>
>>         /// Initializes a new instance of the LeagueMap class.
>>         /// </summary>
>>         public LeagueMap()
>>             : base()
>>         {
>>             var ncaaMap = JoinedSubClass<NcaaLeague>("NcaaLeagueId", sub
>> => sub.Map(x => x.Id));
>>             var mlbMap = JoinedSubClass<MlbLeague>("MlbLeagueId", sub =>
>> sub.Map(x => x.Id));
>>         }
>>    }
>>
>>
>>
>>
>>   var criteria = Session.CreateCriteria(typeof(League))
>>                 .Add(Expression.Eq("Id", id ))
>>                 .UniqueResult<League>();
>>
>> the generated where statement is:
>>
>> WHERE  this_1_.Id* *= 'f5e2e4ef-a682-439f-b0f1-22906b71953d' /* @p0 */
>>
>> it works perfectly if I change it to WHERE* * this_.Id =
>> 'f5e2e4ef-a682-439f-b0f1-22906b71953d' /* @p0 */
>>
>> So you see, it's going off the first subclass to be mapped.  What the hell
>> is going wrong?
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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