【问题标题】:Oracle issue: ORA-00972: identifier is too long / NHibernate.Exceptions.GenericADOException: could not execute queryOracle 问题:ORA-00972:标识符太长/NHibernate.Exceptions.GenericADOException:无法执行查询
【发布时间】:2014-02-19 17:06:37
【问题描述】:

这是 NHibernate 对 Oracle 数据库执行的查询:

select
    compteurra0_.NO_SEQ_CPTE_RAPP_ACCES_INFO_DSQ as NO1_2_,
    compteurra0_.TXT_INFO_COMPL as TXT2_2_,
    compteurra0_.TYP_CPTE_RAPP_ACCES_DSQ as TYP3_2_,
    compteurra0_.VAL_CPTE_RAPP_ACCES_DSQ as VAL4_2_,
    compteurra0_.VAL_CPTE_ATNDU as VAL5_2_,
    compteurra0_.ID_UTIL_CREAT_OCC as ID6_2_,
    compteurra0_.DHC_OCC as DHC7_2_,
    compteurra0_.NO_SEQ_RAPP_ACCES_INFO_DSQ as NO8_2_ 
from
    ESO.ESO_V_CPTE_RAPP_ACCES_DSQ compteurra0_

当我对数据库执行此查询时,它返回一个 Oracle 错误:

  • ORA-00972: identifier is too long

我在互联网上搜索过,发现早在 2005 年就使用 NHibernate 和 Oracle 报告了一个错误:Oracle issue: ORA-00972: identifier is too long

  • 这个问题真的解决了吗?

我发现了另外两个相关的 SO 问题,说明了在 Java 中使用 Hibernate 的解决方案。

CompteurRapportAcces.cs

public class CompteurRapportAcces : AuditableEntity {
    public virtual string InformationComplementaire { get; set; }
    public virtual RapportAccesInformation Rapport { get; set; }
    public virtual TypeCompteur Type { get; set; }
    public virtual int Valeur { get; set; }
    public virtual int ValeurAttendue { get; set; }

    public enum TypeCompteur {
        Ordonnance = 1,            
        Delivrance = 2,
        OrdonnanceElectronique = 3,
        InscriptionRegistreDesRefus = 4
    }
}

CompteurAccesRapport.hbm.xml

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="QueContientMonDSQ.Model" assembly="QueContientMonDSQ">
  <class name="CompteurRapportAcces" table="ESO_V_CPTE_RAPP_ACCES_DSQ" schema="ESO">
    <id name="Id" column="NO_SEQ_CPTE_RAPP_ACCES_INFO_DSQ" type="Int32" unsaved-value="0">
      <generator class="sequence-identity">
        <param name="sequence">ESO_NO_SEQ_CPTE_RAPP_ACCES_DSQ</param>
        <param name="schema">ESO</param>
      </generator>
    </id>
    <property name="InformationComplementaire" column="TXT_INFO_COMPL" type="String" length="1000" />
    <property name="Type" column="TYP_CPTE_RAPP_ACCES_DSQ" type="Int32" />
    <property name="Valeur" column="VAL_CPTE_RAPP_ACCES_DSQ" type="Int32" />
    <property name="ValeurAttendue" column="VAL_CPTE_ATNDU" type="Int32" />
    <property name="Creator" column="ID_UTIL_CREAT_OCC" type="String" length="15" />
    <property name="Created" column="DHC_OCC" />
    <many-to-one name="Rapport" class="RapportAccesInformation" column="NO_SEQ_RAPP_ACCES_INFO_DSQ" />
  </class>
</hibernate-mapping>

hibernate.cfg.xml

<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
    <session-factory name="QueContientMonDSQ">
        <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
        <property name="format_sql">true</property>
        <property name="show_sql">true</property>
        <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
        <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
    </session-factory>
</hibernate-configuration>

【问题讨论】:

    标签: sql .net oracle nhibernate ora-00972


    【解决方案1】:
    <id name="Id" column="NO_SEQ_CPTE_RAPP_ACCES_INFO_DSQ" type="Int32" unsaved-value="0">
      <generator class="sequence-identity">
        <param name="sequence">ESO_NO_SEQ_CPTE_RAPP_ACCES_DSQ</param>
        <param name="schema">ESO</param>
      </generator>
    </id>
    

    标识符(列名)NO_SEQ_CPTE_RAPP_ACCES_INFO_DSQ 的长度必须为

    【讨论】:

    • +1 呵呵!我从另一个表中取了这个列名,只更改了几个字符,却没有注意到INFO_ 部分不是这个序列名的一部分。我在您的电话后进行了验证。非常感谢!很遗憾我自己没有弄清楚! ;-) 谢谢! (我会接受你的回答,但在 9 分钟之前不会让我这样做。)
    • 当然..!!当我们做大事时,有时需要不同的眼睛来发现小虫子! :)
    • 如此真实!这就是我喜欢 SO 和结对编程的原因。感谢您对大事的评论! ;)(距离批准还有 16 秒!)
    猜你喜欢
    • 1970-01-01
    • 2011-02-16
    • 2012-07-09
    • 2012-12-22
    • 1970-01-01
    • 2020-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多