流畅的NHibernate QueryOver没有返回预期的数据? (Oracle)的

时间:2014-06-01 17:48:48

标签: oracle nhibernate where queryover

我有一个班级:

public class WorkOrderStatusTracking {
  private WorkOrderStatusTracking_ID _id = new WorkOrderStatusTracking_ID();
  public virtual WorkOrderStatusTracking_ID ID {
    get { return _id; }
    set { _id = value; }
  }
  public virtual String WORK_ORDER_NBR { get; set; }
  public virtual String WORK_ORDER_TASK { get; set; }
  public virtual Int32 GEN_ARG { get; set; }
  public virtual String HOLD_CODE { get; set; }
  public virtual String HOLD_RELEASE_DATE { get; set; }
}

复合ID:

public class WorkOrderStatusTracking_ID {
  public virtual String WORK_ORDER_NBR { get; set; }
  public virtual String WORK_ORDER_TASK { get; set; }
  public virtual Int32  GEN_ARG { get; set; }
  public override bool Equals(object obj) {
    if (obj == null) {
      return false;
    }
    var t = obj as WorkOrderStatusTracking_ID;
    if (t == null) {
      return false;
    }
    if (
      (WORK_ORDER_NBR == t.WORK_ORDER_NBR) &&
      (WORK_ORDER_TASK == t.WORK_ORDER_TASK) &&
      (GEN_ARG == t.GEN_ARG)
    ) {
      return true;
    }
    return false;
  }
  public override int GetHashCode() {
    return String.Format("{0}|{1}|{2}",
      WORK_ORDER_NBR,
      WORK_ORDER_TASK,
      GEN_ARG
    ).GetHashCode();
  }  
}

和班级地图:

public class WorkOrderStatusTracking_ORM : ClassMap<WorkOrderStatusTracking> {
  public WorkOrderStatusTracking_ORM() {
    Table("TIDWOSTR");
    CompositeId(x => x.ID)
      .KeyProperty(x => x.WORK_ORDER_NBR, x => x.Length(8))
      .KeyProperty(x => x.WORK_ORDER_TASK, x => x.Length(2))
      .KeyProperty(x => x.GEN_ARG);
    Map(x => x.WORK_ORDER_NBR).Length(8);
    Map(x => x.WORK_ORDER_TASK).Length(2);
    Map(x => x.GEN_ARG);
    Map(x => x.HOLD_CODE).Length(3);
    Map(x => x.HOLD_RELEASE_DATE).Length(8);
  }
}

然而,当我跑:

List<WorkOrderStatusTracking> WorkOrderStatusTrackings = session.QueryOver<WorkOrderStatusTracking>()
  .Where(x => x.WORK_ORDER_NBR == "00322384")
  .List<WorkOrderStatusTracking>().ToList();

foreach (WorkOrderStatusTracking w in WorkOrderStatusTrackings) {
  Console.WriteLine(...);
}

我得到零结果......

现在我知道这个where子句存在一个事实条目,如果我.ShowSql()并将查询复制到SQL Developer(这是一个Oracle数据库)它肯定会返回行,此外如果我删除我的.Where()并且放入.Take(10),我得到记录回来。有人有主意吗?尽管生成的查询在SQL Developer中工作,为什么.Where不起作用?

log4net结果:

NHibernate.Cfg.Environment: 2014-06-02 12:11:55,285 [9] INFO  NHibernate.Cfg.Environment - NHibernate 3.3.1.4000 (3.3.1.4000)
NHibernate.Cfg.Environment: 2014-06-02 12:11:55,302 [9] INFO  NHibernate.Cfg.Environment - hibernate-configuration section not found in application configuration file
NHibernate.Cfg.Environment: 2014-06-02 12:11:55,304 [9] INFO  NHibernate.Cfg.Environment - Bytecode provider name : lcg
NHibernate.Cfg.Environment: 2014-06-02 12:11:55,307 [9] INFO  NHibernate.Cfg.Environment - Using reflection optimizer
NHibernate.Cfg.Configuration: 2014-06-02 12:11:55,554 [9] DEBUG NHibernate.Cfg.Configuration - Mapping XML:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"><class xmlns="urn:nhibernate-mapping-2.2" name="Client.WorkOrderStatusTracking, Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="TIDWOSTR"><composite-id name="ID"><key-property name="WORK_ORDER_NBR" type="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><column name="WORK_ORDER_NBR" /></key-property><key-property name="WORK_ORDER_TASK" type="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><column name="WORK_ORDER_TASK" /></key-property><key-property name="GEN_ARG" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><column name="GEN_ARG" /></key-property></composite-id><property name="WORK_ORDER_NBR" type="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><column name="WORK_ORDER_NBR" /></property><property name="WORK_ORDER_TASK" type="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><column name="WORK_ORDER_TASK" /></property><property name="GEN_ARG" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><column name="GEN_ARG" /></property><property name="HOLD_CODE" type="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><column name="HOLD_CODE" /></property><property name="HOLD_RELEASE_DATE" type="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><column name="HOLD_RELEASE_DATE" /></property></class></hibernate-mapping>
NHibernate.Dialect.Dialect: 2014-06-02 12:11:55,677 [9] INFO  NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.Oracle10gDialect
NHibernate.Cfg.XmlHbmBinding.Binder: 2014-06-02 12:11:55,796 [9] INFO  NHibernate.Cfg.XmlHbmBinding.Binder - Mapping class: Client.WorkOrderStatusTracking -> TIDWOSTR
NHibernate.Cfg.XmlHbmBinding.Binder: 2014-06-02 12:11:55,862 [9] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: WORK_ORDER_NBR -> WORK_ORDER_NBR, type: String
NHibernate.Cfg.XmlHbmBinding.Binder: 2014-06-02 12:11:55,864 [9] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: WORK_ORDER_TASK -> WORK_ORDER_TASK, type: String
NHibernate.Cfg.XmlHbmBinding.Binder: 2014-06-02 12:11:55,864 [9] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: GEN_ARG -> GEN_ARG, type: Int32
NHibernate.Tuple.Component.AbstractComponentTuplizer: 2014-06-02 12:11:55,886 [9] DEBUG NHibernate.Tuple.Component.AbstractComponentTuplizer - No custom accessors found for component: Client.WorkOrderStatusTracking_ID, Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
NHibernate.Tuple.Component.AbstractComponentTuplizer: 2014-06-02 12:11:55,892 [9] DEBUG NHibernate.Tuple.Component.AbstractComponentTuplizer - No custom accessors found for component: Client.WorkOrderStatusTracking_ID, Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
NHibernate.Cfg.XmlHbmBinding.Binder: 2014-06-02 12:11:55,917 [9] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ID -> WORK_ORDER_NBR,WORK_ORDER_TASK,GEN_ARG, type: component[WORK_ORDER_NBR,WORK_ORDER_TASK,GEN_ARG]
NHibernate.Cfg.XmlHbmBinding.Binder: 2014-06-02 12:11:55,939 [9] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: WORK_ORDER_NBR -> WORK_ORDER_NBR, type: String
NHibernate.Cfg.XmlHbmBinding.Binder: 2014-06-02 12:11:55,940 [9] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: WORK_ORDER_TASK -> WORK_ORDER_TASK, type: String
NHibernate.Cfg.XmlHbmBinding.Binder: 2014-06-02 12:11:55,942 [9] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: GEN_ARG -> GEN_ARG, type: Int32
NHibernate.Cfg.XmlHbmBinding.Binder: 2014-06-02 12:11:55,943 [9] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: HOLD_CODE -> HOLD_CODE, type: String
NHibernate.Cfg.XmlHbmBinding.Binder: 2014-06-02 12:11:55,944 [9] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: HOLD_RELEASE_DATE -> HOLD_RELEASE_DATE, type: String
NHibernate.Cfg.Configuration: 2014-06-02 12:11:55,954 [9] INFO  NHibernate.Cfg.Configuration - checking mappings queue
NHibernate.Cfg.Configuration: 2014-06-02 12:11:55,955 [9] INFO  NHibernate.Cfg.Configuration - processing one-to-many association mappings
NHibernate.Cfg.Configuration: 2014-06-02 12:11:55,956 [9] INFO  NHibernate.Cfg.Configuration - processing one-to-one association property references
NHibernate.Cfg.Configuration: 2014-06-02 12:11:55,957 [9] INFO  NHibernate.Cfg.Configuration - processing foreign key constraints
NHibernate.Cfg.Configuration: 2014-06-02 12:11:55,959 [9] INFO  NHibernate.Cfg.Configuration - processing filters (second pass)
NHibernate.Dialect.Dialect: 2014-06-02 12:11:55,978 [9] INFO  NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.Oracle10gDialect
NHibernate.Dialect.Dialect: 2014-06-02 12:11:55,984 [9] INFO  NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.Oracle10gDialect
NHibernate.Exceptions.SQLExceptionConverterFactory: 2014-06-02 12:11:56,035 [9] INFO  NHibernate.Exceptions.SQLExceptionConverterFactory - Using dialect defined converter
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,036 [9] INFO  NHibernate.Cfg.SettingsFactory - Generate SQL with comments: disabled
NHibernate.Connection.ConnectionProviderFactory: 2014-06-02 12:11:56,038 [9] INFO  NHibernate.Connection.ConnectionProviderFactory - Initializing connection provider: NHibernate.Connection.DriverConnectionProvider
NHibernate.Connection.ConnectionProvider: 2014-06-02 12:11:56,039 [9] INFO  NHibernate.Connection.ConnectionProvider - Configuring ConnectionProvider
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,043 [9] INFO  NHibernate.Cfg.SettingsFactory - Transaction factory: NHibernate.Transaction.AdoNetWithDistributedTransactionFactory
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,044 [9] INFO  NHibernate.Cfg.SettingsFactory - Optimize cache for minimal puts: False
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,045 [9] INFO  NHibernate.Cfg.SettingsFactory - Connection release mode: auto
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,046 [9] INFO  NHibernate.Cfg.SettingsFactory - Default batch fetch size: 1
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,047 [9] INFO  NHibernate.Cfg.SettingsFactory - echoing all SQL to stdout
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,047 [9] INFO  NHibernate.Cfg.SettingsFactory - Statistics: disabled
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,048 [9] INFO  NHibernate.Cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,050 [9] INFO  NHibernate.Cfg.SettingsFactory - Query translator: NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,052 [9] INFO  NHibernate.Cfg.SettingsFactory - Query language substitutions: {}
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,054 [9] INFO  NHibernate.Cfg.SettingsFactory - cache provider: NHibernate.Cache.NoCacheProvider, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,055 [9] INFO  NHibernate.Cfg.SettingsFactory - Order SQL inserts for batching: disabled
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,056 [9] DEBUG NHibernate.Cfg.SettingsFactory - Wrap result sets: disabled
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,058 [9] INFO  NHibernate.Cfg.SettingsFactory - Batcher factory: NHibernate.AdoNet.NonBatchingBatcherFactory, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,059 [9] INFO  NHibernate.Cfg.SettingsFactory - Default entity-mode: Poco
NHibernate.Cfg.SettingsFactory: 2014-06-02 12:11:56,060 [9] INFO  NHibernate.Cfg.SettingsFactory - Named query checking : enabled
NHibernate.Impl.SessionFactoryImpl: 2014-06-02 12:11:56,081 [9] INFO  NHibernate.Impl.SessionFactoryImpl - building session factory
NHibernate.Impl.SessionFactoryImpl: 2014-06-02 12:11:56,083 [9] DEBUG NHibernate.Impl.SessionFactoryImpl - Session factory constructed with filter configurations : {}
NHibernate.Impl.SessionFactoryImpl: 2014-06-02 12:11:56,084 [9] DEBUG NHibernate.Impl.SessionFactoryImpl - instantiating session factory with properties: {'use_reflection_optimizer'='True', 'connection.provider'='NHibernate.Connection.DriverConnectionProvider', 'connection.driver_class'='NHibernate.Driver.OracleClientDriver, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4', 'dialect'='NHibernate.Dialect.Oracle10gDialect, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4', 'hibernate.dialect'='NHibernate.Dialect.Oracle10gDialect, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4', 'show_sql'='true', 'connection.connection_string'='REMOVED'}
NHibernate.Connection.DriverConnectionProvider: 2014-06-02 12:11:56,087 [9] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
NHibernate.Connection.ConnectionProvider: 2014-06-02 12:11:56,537 [9] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
NHibernate.Tuple.Entity.AbstractEntityTuplizer: 2014-06-02 12:11:56,640 [9] DEBUG NHibernate.Tuple.Entity.AbstractEntityTuplizer - No custom accessors found for entity: Client.WorkOrderStatusTracking
NHibernate.Tuple.Entity.AbstractEntityTuplizer: 2014-06-02 12:11:56,644 [9] DEBUG NHibernate.Tuple.Entity.AbstractEntityTuplizer - No custom accessors found for entity: Client.WorkOrderStatusTracking
NHibernate.Tuple.Entity.PocoEntityTuplizer: 2014-06-02 12:11:56,658 [9] DEBUG NHibernate.Tuple.Entity.PocoEntityTuplizer - Create Instantiator using optimizer for:Client.WorkOrderStatusTracking
NHibernate.SqlCommand.SqlSelectBuilder: 2014-06-02 12:11:56,729 [9] DEBUG NHibernate.SqlCommand.SqlSelectBuilder - The initial capacity was set too low at: 8 for the SelectSqlBuilder that needed a capacity of: 11 for the table TIDWOSTR workorders_
NHibernate.Persister.Entity.AbstractEntityPersister: 2014-06-02 12:11:56,734 [9] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister - Static SQL for entity: Client.WorkOrderStatusTracking
NHibernate.Persister.Entity.AbstractEntityPersister: 2014-06-02 12:11:56,735 [9] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister -  Version select: SELECT WORK_ORDER_NBR, WORK_ORDER_TASK, GEN_ARG FROM TIDWOSTR WHERE WORK_ORDER_NBR = ? AND WORK_ORDER_TASK = ? AND GEN_ARG = ?
NHibernate.Persister.Entity.AbstractEntityPersister: 2014-06-02 12:11:56,736 [9] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister -  Snapshot select: SELECT workorders_.WORK_ORDER_NBR, workorders_.WORK_ORDER_TASK, workorders_.GEN_ARG, workorders_.WORK_ORDER_NBR as WORK1_0_, workorders_.WORK_ORDER_TASK as WORK2_0_, workorders_.GEN_ARG as GEN3_0_, workorders_.HOLD_CODE as HOLD4_0_, workorders_.HOLD_RELEASE_DATE as HOLD5_0_ FROM TIDWOSTR workorders_ WHERE workorders_.WORK_ORDER_NBR=? and workorders_.WORK_ORDER_TASK=? and workorders_.GEN_ARG=?
NHibernate.Persister.Entity.AbstractEntityPersister: 2014-06-02 12:11:56,738 [9] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister -  Insert 0: INSERT INTO TIDWOSTR (HOLD_CODE, HOLD_RELEASE_DATE, WORK_ORDER_NBR, WORK_ORDER_TASK, GEN_ARG) VALUES (?, ?, ?, ?, ?)
NHibernate.Persister.Entity.AbstractEntityPersister: 2014-06-02 12:11:56,738 [9] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister -  Update 0: UPDATE TIDWOSTR SET WORK_ORDER_NBR = ?, WORK_ORDER_TASK = ?, GEN_ARG = ?, HOLD_CODE = ?, HOLD_RELEASE_DATE = ? WHERE WORK_ORDER_NBR = ? AND WORK_ORDER_TASK = ? AND GEN_ARG = ?
NHibernate.Persister.Entity.AbstractEntityPersister: 2014-06-02 12:11:56,739 [9] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister -  Delete 0: DELETE FROM TIDWOSTR WHERE WORK_ORDER_NBR = ? AND WORK_ORDER_TASK = ? AND GEN_ARG = ?
NHibernate.SqlCommand.SqlSelectBuilder: 2014-06-02 12:11:56,770 [9] DEBUG NHibernate.SqlCommand.SqlSelectBuilder - The initial capacity was set too low at: 8 for the SelectSqlBuilder that needed a capacity of: 11 for the table TIDWOSTR workorders0_
NHibernate.Loader.Entity.AbstractEntityLoader: 2014-06-02 12:11:56,776 [9] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader - Static select for entity Client.WorkOrderStatusTracking: SELECT workorders0_.WORK_ORDER_NBR as WORK1_0_0_, workorders0_.WORK_ORDER_TASK as WORK2_0_0_, workorders0_.GEN_ARG as GEN3_0_0_, workorders0_.HOLD_CODE as HOLD4_0_0_, workorders0_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR workorders0_ WHERE workorders0_.WORK_ORDER_NBR=? and workorders0_.WORK_ORDER_TASK=? and workorders0_.GEN_ARG=?
NHibernate.SqlCommand.SqlSelectBuilder: 2014-06-02 12:11:56,778 [9] DEBUG NHibernate.SqlCommand.SqlSelectBuilder - The initial capacity was set too low at: 8 for the SelectSqlBuilder that needed a capacity of: 11 for the table TIDWOSTR workorders0_
NHibernate.Loader.Entity.AbstractEntityLoader: 2014-06-02 12:11:56,778 [9] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader - Static select for entity Client.WorkOrderStatusTracking: SELECT workorders0_.WORK_ORDER_NBR as WORK1_0_0_, workorders0_.WORK_ORDER_TASK as WORK2_0_0_, workorders0_.GEN_ARG as GEN3_0_0_, workorders0_.HOLD_CODE as HOLD4_0_0_, workorders0_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR workorders0_ WHERE workorders0_.WORK_ORDER_NBR=? and workorders0_.WORK_ORDER_TASK=? and workorders0_.GEN_ARG=?
NHibernate.SqlCommand.SqlSelectBuilder: 2014-06-02 12:11:56,779 [9] DEBUG NHibernate.SqlCommand.SqlSelectBuilder - The initial capacity was set too low at: 8 for the SelectSqlBuilder that needed a capacity of: 12 for the table TIDWOSTR workorders0_
NHibernate.Loader.Entity.AbstractEntityLoader: 2014-06-02 12:11:56,780 [9] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader - Static select for entity Client.WorkOrderStatusTracking: SELECT workorders0_.WORK_ORDER_NBR as WORK1_0_0_, workorders0_.WORK_ORDER_TASK as WORK2_0_0_, workorders0_.GEN_ARG as GEN3_0_0_, workorders0_.HOLD_CODE as HOLD4_0_0_, workorders0_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR workorders0_ WHERE workorders0_.WORK_ORDER_NBR=? and workorders0_.WORK_ORDER_TASK=? and workorders0_.GEN_ARG=? for update
NHibernate.SqlCommand.SqlSelectBuilder: 2014-06-02 12:11:56,781 [9] DEBUG NHibernate.SqlCommand.SqlSelectBuilder - The initial capacity was set too low at: 8 for the SelectSqlBuilder that needed a capacity of: 12 for the table TIDWOSTR workorders0_
NHibernate.Loader.Entity.AbstractEntityLoader: 2014-06-02 12:11:56,782 [9] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader - Static select for entity Client.WorkOrderStatusTracking: SELECT workorders0_.WORK_ORDER_NBR as WORK1_0_0_, workorders0_.WORK_ORDER_TASK as WORK2_0_0_, workorders0_.GEN_ARG as GEN3_0_0_, workorders0_.HOLD_CODE as HOLD4_0_0_, workorders0_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR workorders0_ WHERE workorders0_.WORK_ORDER_NBR=? and workorders0_.WORK_ORDER_TASK=? and workorders0_.GEN_ARG=? for update nowait
NHibernate.SqlCommand.SqlSelectBuilder: 2014-06-02 12:11:56,783 [9] DEBUG NHibernate.SqlCommand.SqlSelectBuilder - The initial capacity was set too low at: 8 for the SelectSqlBuilder that needed a capacity of: 12 for the table TIDWOSTR workorders0_
NHibernate.Loader.Entity.AbstractEntityLoader: 2014-06-02 12:11:56,784 [9] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader - Static select for entity Client.WorkOrderStatusTracking: SELECT workorders0_.WORK_ORDER_NBR as WORK1_0_0_, workorders0_.WORK_ORDER_TASK as WORK2_0_0_, workorders0_.GEN_ARG as GEN3_0_0_, workorders0_.HOLD_CODE as HOLD4_0_0_, workorders0_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR workorders0_ WHERE workorders0_.WORK_ORDER_NBR=? and workorders0_.WORK_ORDER_TASK=? and workorders0_.GEN_ARG=? for update nowait
NHibernate.SqlCommand.SqlSelectBuilder: 2014-06-02 12:11:56,785 [9] DEBUG NHibernate.SqlCommand.SqlSelectBuilder - The initial capacity was set too low at: 8 for the SelectSqlBuilder that needed a capacity of: 11 for the table TIDWOSTR workorders0_
NHibernate.Loader.Entity.AbstractEntityLoader: 2014-06-02 12:11:56,786 [9] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader - Static select for action NHibernate.Engine.CascadingAction+MergeCascadingAction on entity Client.WorkOrderStatusTracking: SELECT workorders0_.WORK_ORDER_NBR as WORK1_0_0_, workorders0_.WORK_ORDER_TASK as WORK2_0_0_, workorders0_.GEN_ARG as GEN3_0_0_, workorders0_.HOLD_CODE as HOLD4_0_0_, workorders0_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR workorders0_ WHERE workorders0_.WORK_ORDER_NBR=? and workorders0_.WORK_ORDER_TASK=? and workorders0_.GEN_ARG=?
NHibernate.SqlCommand.SqlSelectBuilder: 2014-06-02 12:11:56,787 [9] DEBUG NHibernate.SqlCommand.SqlSelectBuilder - The initial capacity was set too low at: 8 for the SelectSqlBuilder that needed a capacity of: 11 for the table TIDWOSTR workorders0_
NHibernate.Loader.Entity.AbstractEntityLoader: 2014-06-02 12:11:56,787 [9] DEBUG NHibernate.Loader.Entity.AbstractEntityLoader - Static select for action NHibernate.Engine.CascadingAction+RefreshCascadingAction on entity Client.WorkOrderStatusTracking: SELECT workorders0_.WORK_ORDER_NBR as WORK1_0_0_, workorders0_.WORK_ORDER_TASK as WORK2_0_0_, workorders0_.GEN_ARG as GEN3_0_0_, workorders0_.HOLD_CODE as HOLD4_0_0_, workorders0_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR workorders0_ WHERE workorders0_.WORK_ORDER_NBR=? and workorders0_.WORK_ORDER_TASK=? and workorders0_.GEN_ARG=?
NHibernate.Impl.SessionFactoryObjectFactory: 2014-06-02 12:11:56,790 [9] DEBUG NHibernate.Impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
NHibernate.Impl.SessionFactoryObjectFactory: 2014-06-02 12:11:56,791 [9] DEBUG NHibernate.Impl.SessionFactoryObjectFactory - registered: f105f54666ff41af8b4a14cf8d3713b3(unnamed)
NHibernate.Impl.SessionFactoryObjectFactory: 2014-06-02 12:11:56,792 [9] INFO  NHibernate.Impl.SessionFactoryObjectFactory - no name configured
NHibernate.Impl.SessionFactoryImpl: 2014-06-02 12:11:56,793 [9] DEBUG NHibernate.Impl.SessionFactoryImpl - Instantiated session factory
NHibernate.Impl.SessionFactoryImpl: 2014-06-02 12:11:56,797 [9] DEBUG NHibernate.Impl.SessionFactoryImpl - Checking 0 named HQL queries
NHibernate.Impl.SessionFactoryImpl: 2014-06-02 12:11:56,798 [9] DEBUG NHibernate.Impl.SessionFactoryImpl - Checking 0 named SQL queries
NHibernate.Impl.SessionImpl: 2014-06-02 12:11:56,818 [9] DEBUG NHibernate.Impl.SessionImpl - [session-id=4e41d21c-975d-44a2-8d39-a7c36268c157] opened session at timestamp: 635373079168, for session factory: [/f105f54666ff41af8b4a14cf8d3713b3]
NHibernate.Loader.Criteria.CriteriaQueryTranslator: 2014-06-02 12:11:56,939 [9] DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - put criteria=WORK_ORDER_NBR = String@-66999783(hash) alias=this0_
NHibernate.Loader.Criteria.CriteriaQueryTranslator: 2014-06-02 12:11:56,954 [9] DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - returning alias=this_ for criteria=WORK_ORDER_NBR = String@-66999783(hash)
SELECT this_.WORK_ORDER_NBR as WORK1_0_0_, this_.WORK_ORDER_TASK as WORK2_0_0_, this_.GEN_ARG as GEN3_0_0_, this_.HOLD_CODE as HOLD4_0_0_, this_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR this_ WHERE this_.WORK_ORDER_NBR = ?
NHibernate.AdoNet.AbstractBatcher: 2014-06-02 12:11:57,082 [9] DEBUG NHibernate.AdoNet.AbstractBatcher - Opened new IDbCommand, open IDbCommands: 1
NHibernate.AdoNet.AbstractBatcher: 2014-06-02 12:11:57,084 [9] DEBUG NHibernate.AdoNet.AbstractBatcher - Building an IDbCommand object for the SqlString: SELECT this_.WORK_ORDER_NBR as WORK1_0_0_, this_.WORK_ORDER_TASK as WORK2_0_0_, this_.GEN_ARG as GEN3_0_0_, this_.HOLD_CODE as HOLD4_0_0_, this_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR this_ WHERE this_.WORK_ORDER_NBR = ?
NHibernate.Type.StringType: 2014-06-02 12:11:57,088 [9] DEBUG NHibernate.Type.StringType - binding '00322384' to parameter: 0
NHibernate.Loader.Loader: 2014-06-02 12:11:57,097 [9] INFO  NHibernate.Loader.Loader - SELECT this_.WORK_ORDER_NBR as WORK1_0_0_, this_.WORK_ORDER_TASK as WORK2_0_0_, this_.GEN_ARG as GEN3_0_0_, this_.HOLD_CODE as HOLD4_0_0_, this_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR this_ WHERE this_.WORK_ORDER_NBR = :p0
NHibernate.SQL: 2014-06-02 12:11:57,108 [9] DEBUG NHibernate.SQL - SELECT this_.WORK_ORDER_NBR as WORK1_0_0_, this_.WORK_ORDER_TASK as WORK2_0_0_, this_.GEN_ARG as GEN3_0_0_, this_.HOLD_CODE as HOLD4_0_0_, this_.HOLD_RELEASE_DATE as HOLD5_0_0_ FROM TIDWOSTR this_ WHERE this_.WORK_ORDER_NBR = :p0;:p0 = '00322384' [Type: String (8)]
NHibernate.Connection.DriverConnectionProvider: 2014-06-02 12:11:57,111 [9] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
NHibernate.AdoNet.AbstractBatcher: 2014-06-02 12:11:57,295 [9] DEBUG NHibernate.AdoNet.AbstractBatcher - ExecuteReader took 181 ms
NHibernate.AdoNet.AbstractBatcher: 2014-06-02 12:11:57,297 [9] DEBUG NHibernate.AdoNet.AbstractBatcher - Opened IDataReader, open IDataReaders: 1
NHibernate.Loader.Loader: 2014-06-02 12:11:57,299 [9] DEBUG NHibernate.Loader.Loader - processing result set
NHibernate.Loader.Loader: 2014-06-02 12:12:19,606 [9] DEBUG NHibernate.Loader.Loader - done processing result set (0 rows)
NHibernate.AdoNet.AbstractBatcher: 2014-06-02 12:12:19,610 [9] DEBUG NHibernate.AdoNet.AbstractBatcher - Closed IDataReader, open IDataReaders :0
NHibernate.AdoNet.AbstractBatcher: 2014-06-02 12:12:19,611 [9] DEBUG NHibernate.AdoNet.AbstractBatcher - DataReader was closed after 22496 ms
NHibernate.AdoNet.AbstractBatcher: 2014-06-02 12:12:19,614 [9] DEBUG NHibernate.AdoNet.AbstractBatcher - Closed IDbCommand, open IDbCommands: 0
NHibernate.AdoNet.ConnectionManager: 2014-06-02 12:12:19,616 [9] DEBUG NHibernate.AdoNet.ConnectionManager - aggressively releasing database connection
NHibernate.Connection.ConnectionProvider: 2014-06-02 12:12:19,616 [9] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
NHibernate.Loader.Loader: 2014-06-02 12:12:19,619 [9] DEBUG NHibernate.Loader.Loader - total objects hydrated: 0
NHibernate.Engine.StatefulPersistenceContext: 2014-06-02 12:12:19,620 [9] DEBUG NHibernate.Engine.StatefulPersistenceContext - initializing non-lazy collections
NHibernate.AdoNet.ConnectionManager: 2014-06-02 12:12:19,624 [9] DEBUG NHibernate.AdoNet.ConnectionManager - after autocommit
NHibernate.Impl.SessionImpl: 2014-06-02 12:12:19,625 [9] DEBUG NHibernate.Impl.SessionImpl - transaction completion
NHibernate.AdoNet.ConnectionManager: 2014-06-02 12:12:19,626 [9] DEBUG NHibernate.AdoNet.ConnectionManager - aggressively releasing database connection
NHibernate.Impl.SessionImpl: 2014-06-02 12:12:19,630 [9] DEBUG NHibernate.Impl.SessionImpl - [session-id=4e41d21c-975d-44a2-8d39-a7c36268c157] running ISession.Dispose()
NHibernate.Impl.SessionImpl: 2014-06-02 12:12:19,632 [9] DEBUG NHibernate.Impl.SessionImpl - [session-id=4e41d21c-975d-44a2-8d39-a7c36268c157] executing real Dispose(True)
NHibernate.Impl.SessionImpl: 2014-06-02 12:12:19,634 [9] DEBUG NHibernate.Impl.SessionImpl - closing session
NHibernate.AdoNet.AbstractBatcher: 2014-06-02 12:12:19,635 [9] DEBUG NHibernate.AdoNet.AbstractBatcher - running BatcherImpl.Dispose(true)

2 个答案:

答案 0 :(得分:1)

我能够通过设置NHibernate来使用Oracle的.NET提供程序而不是默认的.NET提供程序。为了做到这一点,我必须做以下事情:

1. Download and unzip/install the appropriate Oracle Data Access Components, in my case the 32bit ODAC for Oracle 11g (ODAC112040Xcopy_32bit.zip).
2. Add a reference to the Oracle.DataAccess.dll found in the .\odp.net20\odp.net\bin\2.x directory.
3. Copy the OraOps11w.dll found in the .\odp.net20\bin directory directly to my projects bin directory.
4. Copy the following DLLs to my projects bin directory (not 100% sure which of these are necessary, I just copied them all)
    .\instantclient_11_2\oci.dll
    .\instantclient_11_2\ocijdbc11.dll
    .\instantclient_11_2\ociw32.dll
    .\instantclient_11_2\orannzsbb11.dll
    .\instantclient_11_2\oraocci11.dll
    .\instantclient_11_2\oraociei11
    .\instantclient_11_2\orasql11
5. Updated my fluent configuration of NHibernate to use the Oracle driver as such:
      Fluently.Configure()
       .Database(OracleClientConfiguration.Oracle10.ConnectionString(OraConStr).Driver<NHibernate.Driver.OracleDataClientDriver>())
       .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>())
       .BuildSessionFactory();

一旦进行了这些更改,所有表访问都能正常工作,并且工作速度更快。因此,我要将此问题归结为提供商/驱动程序问题。我只能假设NHibernate默认使用内置的Microsoft System.Data.OracleClient提供程序,该提供程序已经折旧了一段时间。

虽然这并不能解释为什么当我直接在NHibernate之外使用微软的提供商时,我能够很好地访问该表。在我将项目推向客户的大门之后,我可能会对此进行进一步的研究,因为这是一个令人费解的困境,我无法解决一个好的难题。

答案 1 :(得分:0)

也适用于.Net 4.0。