HQL:替换元素()
HQL: replace on elements()
我有以下 HQL 查询:
from Paperboy as paperboy
where
replace(replace(paperboy._mobile, ' ', ''), '/', '') = :nr or replace(replace(paperboy._phone, ' ', ''), '/', '') = :nr or
:nr in elements(paperboy._additionalPhoneNumbers)
现在的问题是,我还必须替换 _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>
这可能有用
select
paperboy
from
Paperboy as paperboy left join paperboy._additionalPhoneNumbers number
where
replace(replace(paperboy._mobile, ' ', ''), '/', '') = :nr or
replace(replace(paperboy._phone, ' ', ''), '/', '') = :nr or
replace(replace(number, ' ', ''), '/', '') = :nr
我有以下 HQL 查询:
from Paperboy as paperboy
where
replace(replace(paperboy._mobile, ' ', ''), '/', '') = :nr or replace(replace(paperboy._phone, ' ', ''), '/', '') = :nr or
:nr in elements(paperboy._additionalPhoneNumbers)
现在的问题是,我还必须替换 _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>
这可能有用
select
paperboy
from
Paperboy as paperboy left join paperboy._additionalPhoneNumbers number
where
replace(replace(paperboy._mobile, ' ', ''), '/', '') = :nr or
replace(replace(paperboy._phone, ' ', ''), '/', '') = :nr or
replace(replace(number, ' ', ''), '/', '') = :nr