I have the following classes and relationships:
- PhysicalNetworkDevice inherits from ManagedElement
- ManagedElement bidirectional 1-M PropertyValue (C# properties: PropertyValues in ManagedElement class; PManagedElement in PropertyValue class)
- PropertyValue unidirectional M-1 PropertyTemplate (C# property: PPropertyTemplate in PropertyValue)
I just want to create an HQL query as follows: select pnd from PhysicalNetworkDevice pnd where pnd.PropertyValues.PPropertyTemplate.Name = 'CPUUtil';
But I get the error: expecting 'elements' or 'indices' after PPropertyTemplate
I tried the following and they don't work:
select pnd from PhysicalNetworkDevice pnd where all elements(pnd.PropertyValues.PPropertyTemplate.Name) = 'CPUUtil';
select pnd from PhysicalNetworkDevice pnd where all elements(pnd.PropertyValues.PPropertyTemplate).Name = 'CPUUtil';
I then did a theta-styl join (as follows) and it worked BUT ... the query took over 15 seconds to execute with only a few thousand rows in the SQL Server db tables (with the nHibernate log file growing by 70mb each time the query executed -- log4net level was set to DEBUG):
select pnd from PhysicalNetworkDevice pnd, PropertyValue pv, PropertyTemplate pt
where (pv.PManagedElement = pnd.ID) and (pv.PPropertyTemplate.ID = pt.ID)
and (pt.Name = 'CPUUtil')
nHibernate Class Mappings:
<class name="ManagedElement, Domain" table="dbo.tblManagedElement">
<bag name="PropertyValues" cascade="all-delete-orphan" outer-join="true" inverse="true">
<key column="FK_ManagedElementID"/>
<one-to-many class="PropertyValue, Domain"/>
</bag>
<joined-subclass name="PhysicalNetworkDevice, Domain" table="tblDevice">
...
</joined-subclass>
<class>
<class name="PropertyTemplate, Domain" table="dbo.tblPropertyTemplate">
<property name="Name" column="PropertyTemplateName"/>
</class>
<class name="PropertyValue, Domain" table="dbo.tblPropertyValue">
<many-to-one
name="PManagedElement"
column="FK_ManagedElementID"
class="ManagedElement, Domain"
not-null="true"
/>
<!-- Unidirectional -->
<many-to-one
name="PPropertyTemplate"
column="FK_PropertyTemplateID"
class="PropertyTemplate, Domain"
not-null="true"
outer-join="true"
/>
</class>
Thanks,
Bill
_________________ metazone
|