Actualy, we need some hql surrogate of left join to find all Persons
wich are not within Departments
var result = sess.CreateQuery(@"
select p
from
Person p, //Person need to be even
if no department exists like with left join in sql
Department d
where
p.Path like d.Path + cast(d.Id as String) + '/%'
and d is null
")
Thanks!
PS: Department and Person are Entities extended Obj
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Helpdesk" namespace="Helpdesk">
<class name="Obj" discriminator-value="9">
<id name="Id">
<generator class="native" />
</id>
<discriminator column="Typee" type="Int32"/>
<timestamp name="Modifed"/>
<property name="Path" access="nosetter.camelcase-underscore" not-
null="true"/>
<property name="Name" column="Namee" not-null="true"/>
<property name ="IsFolder" access="nosetter.camelcase-underscore"/
>
<property name="Note"/>
<property name="Created" not-null="true"/>
<many-to-one name="Owner" column ="Ownerr" />
<many-to-one name ="Parent" access="nosetter.camelcase-underscore"/
>
<set name="Children" inverse="true">
<key column="Parent"/>
<one-to-many class="Obj"/>
</set>
<set name="Attachments" table="Obj_Attachments" cascade="save-
update">
<key column="Obj"/>
<many-to-many column="Attachment" class="Filee"/>
</set>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Helpdesk" namespace="Helpdesk">
<subclass name="Person" extends ="Obj" discriminator-value="0">
<join table="Person">
<key column="Id"/>
<property name="FirstName"/>
<property name ="SecondName"/>
<property name="MiddleName"/>
<property name="Email"/>
<property name ="Phones"/>
<!--
<list name="Phones" table="Person_Phones">
<key column="Ownerr"/>
<index column="Indexx"/>
<element column="Phone" type="String"/>
</list>
-->
</join>
</subclass>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Helpdesk" namespace="Helpdesk">
<subclass name="Department" extends ="Obj" discriminator-value="32">
<join table="Department">
<key column="Id"/>
<property name ="Address"/>
</join>
</subclass>
</hibernate-mapping>
Thanks!
On Sep 17, 3:17 pm, alexey_baranov <[email protected]> wrote:
> O, I see. We will rewrite query. Another question Is HQL may join
> entities only if there is a refference-way from one to another?
>
> Thanks!
>
> On Sep 16, 11:17 pm, Fabio Maulo <[email protected]> wrote:
>
> > mmm the "path" mentioned in the exception message is not your property
> > called "Path" but:
> > left join Department <=== from where come Department ? it is a property of
> > what ?
> > The other error you will find is "on"; "on" is not HQL
> > The other strange thing is: :rootDepartmentPath2 + '%' ; why don't do it in
> > the parameter ?
>
> > before say "We try to use HQL first time and found exception" perhaps would
> > be more productive to think : "We try to use HQL first time and perhpas we
> > have not studied it enough".
>
> > On Thu, Sep 16, 2010 at 1:08 PM, alexey_baranov <[email protected]> wrote:
> > > Hello!
>
> > > We try to use HQL first time and found exception. What does this "Path
> > > expected for join!" means ? Path is a string not null property. Wwe
> > > try to use this HQL to find Persons within Department rootDepartment
> > > and not in subdepartments.
>
> > > Path expected for join! [
> > > select p
> > > from
> > > Helpdesk.Person p
> > > left join Department d on p.Path like d.Path +
> > > cast(d.Id as String) + '/%'
> > > where
> > > p.Path like :rootDepartmentPath2 + '%'
> > > and d.Path like :rootDepartmentPath2 + '%'
> > > and d is null
> > > ]
>
> > > Thanks.
>
> > > --
> > > 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]<nhusers%[email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=en.
>
> > --
> > 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.