Will Marcouiller
Will Marcouiller

Reputation: 24142

Oracle issue: ORA-00972: identifier is too long / NHibernate.Exceptions.GenericADOException: could not execute query

This is the query performed by NHibernate against the Oracle database:

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_

When I perform this query against the database, it returns an Oracle error:

I have searched the Internet and found that a bug was reported back in 2005 using NHibernate and Oracle: Oracle issue: ORA-00972: identifier is too long

I have found two other related SO questions stating resolutions using Hibernate in Java.

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>

Upvotes: 0

Views: 6809

Answers (1)

Maheswaran Ravisankar
Maheswaran Ravisankar

Reputation: 17920

<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>

The length of identifier(column name) NO_SEQ_CPTE_RAPP_ACCES_INFO_DSQ must be <= 30.

Upvotes: 7

Related Questions