这是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>
答案 0 :(得分:7)
<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
的长度必须<= 30。