У меня есть следующий HQL-запрос:HQL: заменить на элементы()
from Paperboy as paperboy where replace(replace(paperboy._mobile, ' ', ''), '/', '') = :nr or replace(replace(paperboy._phone, ' ', ''), '/', '') = :nr or :nr in elements(paperboy._additionalPhoneNumbers)
Теперь проблема в том, что я также должен заменить пробелы и slashs в _additionalPhoneNumbers. Возможно ли это через HQL?
Я пытался что-то вроде
from Paperboy as paperboy where replace(replace(paperboy._mobile, ' ', ''), '/', '') = :nr or replace(replace(paperboy._phone, ' ', ''), '/', '') = :nr or :nr in elements(replace(replace(paperboy._additionalPhoneNumbers, ' ', ''), '/', ''))
, но это бросает исключение. Отображение Paperboy как это:
<class name="Paperboy"
table="tblPaperboy"
lazy="false">
<id name="_key"
column="Id"
access="field" >
<generator class="assigned"/>
</id>
<property name ="_businessId" column="BusinessId" access="field" />
<many-to-one name="_agency" class="Agency" access="field" column="AgencyKey" />
<property name ="_lastname" column="Lastname" access ="field" />
<property name ="_firstname" column="Firstname" access ="field" />
<property name ="_phone" column="Phone" access ="field" />
<property name ="_mobile" column="Mobile" access ="field" />
<bag name="_additionalPhoneNumbers"
access="field"
fetch="subselect"
lazy="false"
table="tblPaperboyAdditionalPhoneNumbers">
<key column="PaperboyId"/>
<element column="PhoneNumber"
type="string"/>
</bag>
</class>
Кажется, работает! Большой!!! Большое спасибо!!! – Tobias
Мысль о соединении вызовет проблемы из-за сопоставления элементов. – Tobias
NHibernate достаточно умен, чтобы абстрагироваться от различий ссылок, композитной коллекции и коллекции элементов – Firo