I have an object that has a IList<string> propery of aliases for the item.
What I want to do is get an object, or list of objects that have the provided alias.
The native sql query would look like:
Code:
select * from ANALYTES a
inner join ANALYTE_ALIASES aa
on aa.ANALYTE_ID = a.ANALYTE_ID
where aa.ALIAS = :the alias
what would the HQL query look like, or is there a criteria query that could be used? Projection on the alias column?
or do I have to use a subquery
Code:
from ANALYTE a where a.ID in (select ANALYTE_ID from ANALYTE_ALIAS where ALIAS = :alias)
There is no ANALYTE_ALIAS class, it's a table, so the previous query is kind of an HQL hybrid.
Mapping documents:Code:
<class name="AMEC.EE.Sage.Domain.Persistence.Adm.Proxy.Analyte, Sage.Domain.Persistence.Adm"
table="ANALYTES"
schema="ADM"
lazy="false">
<id name="id"
column="ANALYTE_ID"
type="System.Int32"
access="field"
unsaved-value="0">
<generator class="identity" />
</id>
<property name="CommonName"
column="COMMON_NAME"
type="System.String"
length="150"
not-null="true"
unique="false" />
<property name="ShortName"
column="SHORT_NAME"
type="System.String"
length="35"
not-null="false"
unique="false" />
<property name="RowGuid"
column="ROWGUID"
type="System.Guid"
not-null="true"
unique="true" />
<bag name="Aliases"
inverse="false"
cascade="all-delete-orphan"
lazy="true"
table="ANALYTE_ALIAS"
schema="ADM">
<key column="ANALYTE_ID" />
<element column="ALIAS"
type="System.String"
length="150"
not-null="true"
unique="true" />
</bag>
<!-- TODO: Map alternate IDs-->
<map name="AlternateIDs"
inverse="false"
cascade="all-delete-orphan"
lazy="true"
schema="ADM"
table="ANALYTE_IDS">
<key column="ANALYTE_ID"/>
<index-many-to-many column="ENTITY_ID"
class="AMEC.EE.Sage.Domain.Entities.Core.IEntity, Sage.Domain.Entities.Core"/>
<element column="ALT_ID"
type="System.String"
length="50"
not-null="true"
unique="false"/>
</map>
</class>