升级到 Nhibernate 3 后出现奇怪的问题

发布于 2024-10-17 20:00:44 字数 4006 浏览 1 评论 0原文

你好 我有一个映射为采用日期字段的查询。 升级到 NHibernate 3 后出现以下错误:

could not execute query
[ select a.agency_num, cd.comp_name, sd.sib_number, sd.sib_type_label,
ad.add_line1, ad.add_line2, ad.add_line3, ad.add_line4, ad.post_code,
ad.country_label
from
agency a, company_details cd, sib_dets sd, address ad
where
a.contact_ser = cd.contact_ser
and a.contact_ser = sd.contact_ser
and a.contact_ser = ad.contact_ser
and a.current_ser = 10
and a.start_date <= ?
and (a.end_date is null or a.end_date >= ?)
and cd.current_ser = 10
and cd.start_date <= ?
and (cd.end_date is null or cd.end_date >= ?)
and sd.current_ser = 10
and sd.start_date <= ?
and (sd.end_date is null or sd.end_date >= ?)
and ad.current_ser = 10
and ad.start_date <= ?
and (ad.end_date is null or ad.end_date >= ?) ]
  Name:dateValid - Value:18/02/2011 00:00:00
[SQL: select a.agency_num, cd.comp_name, sd.sib_number,
sd.sib_type_label,
ad.add_line1, ad.add_line2, ad.add_line3, ad.add_line4, ad.post_code,
ad.country_label
from
agency a, company_details cd, sib_dets sd, address ad
where
a.contact_ser = cd.contact_ser
and a.contact_ser = sd.contact_ser
and a.contact_ser = ad.contact_ser
and a.current_ser = 10
and a.start_date <= ?
and (a.end_date is null or a.end_date >= ?)
and cd.current_ser = 10
and cd.start_date <= ?
and (cd.end_date is null or cd.end_date >= ?)
and sd.current_ser = 10
and sd.start_date <= ?
and (sd.end_date is null or sd.end_date >= ?)
and ad.current_ser = 10
and ad.start_date <= ?
and (ad.end_date is null or ad.end_date >= ?)]

内部异常是: {“参数名称为‘p0’的 IfxParameter 已包含在 this IfxParameterCollection."}

有人知道这是为什么吗?它在以前的版本下工作正常 NHibernate

这是我的 NHibernate 代码:

using (ISession session = NHibernateHelper.OpenSession(FACTORY_NAME))
    {
    IQuery query = session.GetNamedQuery("GetAllAgents");
    query.SetDateTime("dateValid", dateValid.Date);
    agents = query.List<AgencySearchData>();
    }

这是我的映射文件:

        <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
               assembly="SeiDomain"
               namespace="Sei.Domain.Entity">
      <class name="AgencySearchData">
        <id name="AgencyNumber" column="agency_num"/>
        <property name="Name" column="comp_name" />
        <property name="SibNumber" column="sib_number" />
        <property name="SibType" column="sib_type_label" />
        <property name="Address1" column="add_line1" />
        <property name="Address2" column="add_line2" />
        <property name="Address3" column="add_line3" />
        <property name="Address4" column="add_line4" />
        <property name="Postcode" column="post_code" />
        <property name="Country" column="country_label" />
      </class>
      <sql-query name="GetAllAgents">
        <return alias="agencySearchData" class="AgencySearchData"/>
        <![CDATA[select a.agency_num, cd.comp_name, sd.sib_number,
    sd.sib_type_label,
    ad.add_line1, ad.add_line2, ad.add_line3, ad.add_line4, ad.post_code,
    ad.country_label
    from
    agency a, company_details cd, sib_dets sd, address ad
    where
    a.contact_ser = cd.contact_ser
    and a.contact_ser = sd.contact_ser
    and a.contact_ser = ad.contact_ser
    and a.current_ser = 10
    and a.start_date <= :dateValid
    and (a.end_date is null or a.end_date >= :dateValid)
    and cd.current_ser = 10
    and cd.start_date <= :dateValid
    and (cd.end_date is null or cd.end_date >= :dateValid)
    and sd.current_ser = 10
    and sd.start_date <= :dateValid
    and (sd.end_date is null or sd.end_date >= :dateValid)
    and ad.current_ser = 10
    and ad.start_date <= :dateValid
    and (ad.end_date is null or ad.end_date >= :dateValid)]]>
      </sql-query>
    </hibernate-mapping>

Hi
I have a query mapped to take a date field.
After upgrading to NHibernate 3 I get the following error:

could not execute query
[ select a.agency_num, cd.comp_name, sd.sib_number, sd.sib_type_label,
ad.add_line1, ad.add_line2, ad.add_line3, ad.add_line4, ad.post_code,
ad.country_label
from
agency a, company_details cd, sib_dets sd, address ad
where
a.contact_ser = cd.contact_ser
and a.contact_ser = sd.contact_ser
and a.contact_ser = ad.contact_ser
and a.current_ser = 10
and a.start_date <= ?
and (a.end_date is null or a.end_date >= ?)
and cd.current_ser = 10
and cd.start_date <= ?
and (cd.end_date is null or cd.end_date >= ?)
and sd.current_ser = 10
and sd.start_date <= ?
and (sd.end_date is null or sd.end_date >= ?)
and ad.current_ser = 10
and ad.start_date <= ?
and (ad.end_date is null or ad.end_date >= ?) ]
  Name:dateValid - Value:18/02/2011 00:00:00
[SQL: select a.agency_num, cd.comp_name, sd.sib_number,
sd.sib_type_label,
ad.add_line1, ad.add_line2, ad.add_line3, ad.add_line4, ad.post_code,
ad.country_label
from
agency a, company_details cd, sib_dets sd, address ad
where
a.contact_ser = cd.contact_ser
and a.contact_ser = sd.contact_ser
and a.contact_ser = ad.contact_ser
and a.current_ser = 10
and a.start_date <= ?
and (a.end_date is null or a.end_date >= ?)
and cd.current_ser = 10
and cd.start_date <= ?
and (cd.end_date is null or cd.end_date >= ?)
and sd.current_ser = 10
and sd.start_date <= ?
and (sd.end_date is null or sd.end_date >= ?)
and ad.current_ser = 10
and ad.start_date <= ?
and (ad.end_date is null or ad.end_date >= ?)]

and the inner exception is:
{"The IfxParameter with ParameterName 'p0' is already contained by
this IfxParameterCollection."}

Anyone know why this is? It works fine under the previous version on
NHibernate

Here is my NHibernate code:

using (ISession session = NHibernateHelper.OpenSession(FACTORY_NAME))
    {
    IQuery query = session.GetNamedQuery("GetAllAgents");
    query.SetDateTime("dateValid", dateValid.Date);
    agents = query.List<AgencySearchData>();
    }

and here is my mapping file:

        <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
               assembly="SeiDomain"
               namespace="Sei.Domain.Entity">
      <class name="AgencySearchData">
        <id name="AgencyNumber" column="agency_num"/>
        <property name="Name" column="comp_name" />
        <property name="SibNumber" column="sib_number" />
        <property name="SibType" column="sib_type_label" />
        <property name="Address1" column="add_line1" />
        <property name="Address2" column="add_line2" />
        <property name="Address3" column="add_line3" />
        <property name="Address4" column="add_line4" />
        <property name="Postcode" column="post_code" />
        <property name="Country" column="country_label" />
      </class>
      <sql-query name="GetAllAgents">
        <return alias="agencySearchData" class="AgencySearchData"/>
        <![CDATA[select a.agency_num, cd.comp_name, sd.sib_number,
    sd.sib_type_label,
    ad.add_line1, ad.add_line2, ad.add_line3, ad.add_line4, ad.post_code,
    ad.country_label
    from
    agency a, company_details cd, sib_dets sd, address ad
    where
    a.contact_ser = cd.contact_ser
    and a.contact_ser = sd.contact_ser
    and a.contact_ser = ad.contact_ser
    and a.current_ser = 10
    and a.start_date <= :dateValid
    and (a.end_date is null or a.end_date >= :dateValid)
    and cd.current_ser = 10
    and cd.start_date <= :dateValid
    and (cd.end_date is null or cd.end_date >= :dateValid)
    and sd.current_ser = 10
    and sd.start_date <= :dateValid
    and (sd.end_date is null or sd.end_date >= :dateValid)
    and ad.current_ser = 10
    and ad.start_date <= :dateValid
    and (ad.end_date is null or ad.end_date >= :dateValid)]]>
      </sql-query>
    </hibernate-mapping>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆依然 2024-10-24 20:00:44

我相信这可能与 NH-2529 有关。

看看该修复是否适合您,然后投票。

I believe this might be related to NH-2529.

See if the fix works for you, and vote for it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文