8.1.3
http://nhforge.org/doc/nh/en/index.html#inheritance-tablepersubclass-discriminator
2008/10/18 Jason Meckley <[EMAIL PROTECTED]>
>
> Digging more into this. I have examined union-class and began looking
> to simply join. Union-doesn't work as it messes with the current
> identity and the queries don't look that effecient (no predicates on
> the union-ized sub-queries) Just started looking into the join type.
> I found this mentioned on ayende's blog. Is there any documentation on
> this feature?
>
> On Oct 16, 9:51 am, Jason Meckley <[EMAIL PROTECTED]> wrote:
> > mappings:
> > Status is abstract with 1:1 relations to other tables.
> > Some of the tables have a property ReviewDate, others do not.
> > in this snippet PrepareStatus and InServiceStatus have the ReviewDate
> > property. The DisposeStatus does not.
> > <hibernate-mapping>
> > <class name="Status" abstract="true">
> > <id name="Id">
> > <generator class="identity" />
> > </id>
> > ...
> > </class>
> >
> > <joined-subclass extends="Status" name="PrepareStatus">
> > <key column="id" on-delete="cascade" />
> > <property name="ReviewDate" />
> > ...
> > </joined-subclass>
> >
> > <joined-subclass extends="Status" name="InServiceStatus">
> > <key column="id" on-delete="cascade" />
> > <property name="ReviewDate" />
> > ...
> > </joined-subclass>
> >
> > <joined-subclass extends="Status" name="DisposeStatus">
> > <key column="id" on-delete="cascade" />
> > ...
> > </joined-subclass>
> > </hibernate-mapping>
> >
> > code:
> > I want to return all statuses where ReviewDate is between 2 dates.
> > DetachedCriteria criteria = Repository<AnInterfaceImplementedByStatus>
> > .CreateDetachedCriteria()
> > .Add(Restrictions.Between("ReviewDate", since, before));
> >
> > return Repository<AnInterfaceImplementedByStatus>.FindAll(criteria);
> >
> > Sql:
> > however the sql produced looks like this
> > select ...
> > from Status s
> > left join PrepareStatus p on s.Id = p.Id
> > left join InServiceStatus i on s.Id = i.Id
> > left join DisposeStatus d on s.Id = d.Id
> > where p.ReviewDate between @p0 and @p1
> >
> > So only PreparedStatus records are returned.
> > How would I alter my criteria to generate sql similar to?
> > select ...
> > from Status s
> > left join PrepareStatus p on s.Id = p.Id
> > left join InServiceStatus i on s.Id = i.Id
> > left join DisposeStatus d on s.Id = d.Id
> > where p.ReviewDate between @p0 and @p1
> > or i.ReviewDate between @p0 and @p1
> >
> > I tried this:
> > DetachedCriteria criteria = Repository<AnInterfaceImplementedByStatus>
> > .CreateDetachedCriteria()
> > .CreateAlias("PrepareStatus", "p")
> > .CreateAlisa("InServiceStatus", "i")
> > .Add(Restrictions.Between("p.ReviewDate", since, before) |
> > Restrictions.Between("i.ReviewDate", since, before));
> >
> > return Repository<AnInterfaceImplementedByStatus>.FindAll(criteria);
> >
> > But NH throws an excpetion: Status does not have a property named
> > PrepareStatus. Which makes sense since PrepareStatus is an
> > inheritance, not a property.
> >
> > thank you in advance.
> > Jason
> >
>
--
Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---