-1

fluentmapping を使用して、Oracle の既存のデータベースに接続しようとしています。お客様よりマッピングを取得しました

public CustomerMapping()
    {

         Not.LazyLoad();
        Id(x => x.Cst_Recid).GeneratedBy.Increment() ;
    }

そして私はセッションを作成しようとしています

public static ISessionFactory CreateSessionFactory()
    {
        return Fluently
            .Configure()
            .Database(OracleClientConfiguration.Oracle10.ConnectionString
            ("...."))
            .Mappings(m =>
             {
                 m.FluentMappings.AddFromAssemblyOf<CustomerMapping>();

             })
             .BuildConfiguration() 
             .BuildSessionFactory();
    }

sessionFactory を試して作成するトライアル クラスがあります。

public class MyDataProvider
{
    public static  Customer GetCustomerById(long customerId)
    {
        ISessionFactory sessionFactory = SessionFactory.CreateSessionFactory(); 
        ISession session = sessionFactory.OpenSession();
          return session.Linq<Customer>().Where(x => x.Cst_Recid.Equals(temp)).FirstOrDefault();

    }


}

セッションを開いてアクティブ化しても、ID で顧客を取得できません...

テストは非常に単純です - 選択したアクティビティをチェックするだけです

    [Test]
    public void CanGetCustomerById()
    {
        MyDataProvider provider = new MyDataProvider();
        Assert.AreEqual(33941, MyDataProvider.GetCustomerById(33941).Cst_Recid);

    }

間違いがあります -

TestCase '...DataLayer.Tests.CustomerMappingTests.CanGetCustomerById' が失敗しました: NHibernate.ADOException : クエリを実行できませんでした [ select * from ( as Cst4_0_0_, this_.Cst_Insdbdt as Cst5_0_0_, this_.Cst_Insdbuser as Cst6_0_0_, this_.Cst_Joingroup_Dt as Cst7_0_0_, this_.Cst_Last_Name as Cst8_0_0_, this_.Cst_Lastupddt as Cst9_0_0_, this_.Cst_Lastupduser as Cst10_0_0_, this_.Cst_Tat_Lakoach_Meshalem as Cst11_0_0_, this_.Cst_Typeid as Cst12_0_0_ , this_.Cst_Tziyun_Meshalem_Rashi_Only as Cst13_0_0_, this_.Cst_Tziyun_Mizdamen as Cst14_0_0_ FROM "Customer" this_ WHERE this_.Cst_Recid = :p0 ) where rownum <=:p1 ] 定位置パラメーター: #0>33941 [SQL: select * from ( SELECT this_.Cst_Recid Cst1_0_0_として、this_.Cst_Customerid as Cst2_0_0_, this_.Cst_First_Name as Cst3_0_0_, this_.Cst_Group_Recid as Cst4_0_0_, this_.Cst_Insdbdt as Cst5_0_0_, this_.Cst_Insdbuser as Cst6_0_0_, this_.Cst_Joingroup_Dt as Cst7_0_0_, this_.Cst_Last_Name as Cst8_0_0_, this_.Cst_Lastupddt as Cst9_0_0_, this_. Cst_Lastupduser as Cst10_0_0_, this_.Cst_Tat_Lakoach_Meshalem as Cst11_0_0_, this_.Cst_Typeid as Cst12_0_0_, this_.Cst_Tziyun_Meshalem_Rashi_Only as Cst13_0_0_, this_.Cst_Tziyun_Mizdamen as Cst14_0_0_ FROM "Customer" this_ WHERE this_.Cst_Recid = :p0 ) where rownum <=:p1] --- -> System.Data.OracleClient.OracleException : ORA-00942: テーブルまたはビューが存在しませんCst_Joingroup_Dt as Cst7_0_0_, this_.Cst_Last_Name as Cst8_0_0_, this_.Cst_Lastupddt as Cst9_0_0_, this_.Cst_Lastupduser as Cst10_0_0_, this_.Cst_Tat_Lakoach_Meshalem as Cst11_0_0_, this_.Cst_Typeid as Cst12_0_0_, this_.Cst_Tziyun_Meshalem_Rashi_Only as Cst13_0_0_, this_.Cst_Tziyun_Mizdamen as Cst14_0_0_ FROM "Customer" this_ WHERE this_.Cst_Recid = :p0 ) where rownum <=:p1] ----> System.Data.OracleClient.OracleException : ORA-00942: テーブルまたはビューが存在しませんCst_Joingroup_Dt as Cst7_0_0_, this_.Cst_Last_Name as Cst8_0_0_, this_.Cst_Lastupddt as Cst9_0_0_, this_.Cst_Lastupduser as Cst10_0_0_, this_.Cst_Tat_Lakoach_Meshalem as Cst11_0_0_, this_.Cst_Typeid as Cst12_0_0_, this_.Cst_Tziyun_Meshalem_Rashi_Only as Cst13_0_0_, this_.Cst_Tziyun_Mizdamen as Cst14_0_0_ FROM "Customer" this_ WHERE this_.Cst_Recid = :p0 ) where rownum <=:p1] ----> System.Data.OracleClient.OracleException : ORA-00942: テーブルまたはビューが存在しませんp1] ----> System.Data.OracleClient.OracleException : ORA-00942: テーブルまたはビューが存在しませんp1] ----> System.Data.OracleClient.OracleException : ORA-00942: テーブルまたはビューが存在しません

彼が実行しようとしているクエリは、 FluentNHibernate によって自動的に構築されます。引用符を削除すると、クエリが正しく実行され、結果が得られます..問題は、クエリを希望どおりに変更できないことです..おそらく問題は、Oracle 11 g を使用しており、FluentNhibernate が Oracle 9 または10 ?

どんな助けにも感謝します。

4

1 に答える 1

2

私の以前の答えは間違っていました。もう一度やり直させてください!

Oracleでオブジェクト名を引用すると、大文字と小文字が区別されます。CUSTOMERテーブルは「Customer」として引用されていますが、これは「CUSTOMER」として引用されているのと同じではありません。

SQL> select * from "dual";
select * from "dual"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "Dual";
select * from "Dual"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "DUAL";

D
-
X

私はまだFluidNHibernateについて何も知りませんが、「Customers」テーブルの代わりに「CUSTOMER」テーブルを検索するように取得することはできますか?

または、CUSTOMERSテーブルを探しているものが他にない場合は、名前を「Customers」に変更できます...ただし、これにより、CUSTOMERSテーブルへの参照が壊れます。

SQL> create table CUSTOMERS (x int);

Table created.

SQL> insert into CUSTOMERS (x) values (1);

1 row created.

SQL> select * from CUSTOMERS;

         X
----------
         1

SQL> select * from "Customers";
select * from "Customers"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "CUSTOMERS";

         X
----------
         1

SQL> alter table CUSTOMERS rename to "Customers";

Table altered.

SQL> select * from CUSTOMERS;
select * from CUSTOMERS
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "Customers";

         X
----------
         1

幸運を!これがお役に立てば幸いです...

于 2009-10-08T13:50:45.317 に答える