NHibernate Step by Step (一) Hello,NHibernate!

NHibernate Step by Step (一) Hello,NHibernate!

NHibernate Step by Step (一)  Hello,NHibernate!
 好了,今天我們正式開始NHibernate的歷程,在第一次的練習中,我將盡量詳細地講解環境的配置,以後將不再詳細解釋。

基本的軟件環境如下:
1.NHibernate www.nhibernate.org 當前版本是1.0.2
2.Code Smith http://www.codesmithtools.com/
3.NHibernate模板 點擊這裏下載
當然,少不了VS2005跟SQLServer了,我這裏用的是SQLServer2005,教程用在SQLServer2000上應該沒有問題,默認情況下,我將建立並使用一個叫NHibernate的數據庫。

首先,我們先建立一個最簡單的Person表,如下完整腳本(你可以進行修改以適合自己的數據庫):

USE [NHibernate]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Person](
    [id] [
int] IDENTITY(1,1) NOT NULL,
    [name] [varchar](
50) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED 
(
    [id] ASC
)WITH (IGNORE_DUP_KEY 
= OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

僅有兩個字段,一個自動增長的id,一個name,如下:

 
然後將下載的nhibernate-template解壓,打開Code Smith,將模板加入”Template Explorer”,如下:

 
然後在其中的NHibernate.cst上點右鍵,選擇“Execute”,彈出設置窗口,在左邊的屬性窗口進行如下設置:

 
注意:SourceDatabase屬性在第一次選擇時需要配置一個連接字符串,配置好後Code Smith將記錄下來。 Assembly屬性代表的是生成文件的默認Assembly名,而NameSpace,顧名思義,就是使用的命名空間了,這裏我們全部使用” Test.Model”,請記住這個名字,點擊左下角的Generate,將會在指定的輸出目錄下產生兩個文件:Person.cs, Person.hbm.xml。

好了,NHibernate需要的類文件和映射文件生成完了,我們可以開始幹活了!(生成NHibernate文件均是如此步驟,以後不再贅述)

新建立一個類庫工程,爲了簡潔起見,我們命名爲Model,需要注意的是,爲了跟剛纔生成的文件對應,我們需要在Model工程的屬性頁中將起Assembly名字設爲上面的“Test.Model”,如下:

 
然後將剛纔生成的兩個文件Person.cs和Person.hbm.xml加入到Model工程中來,選中Person.hbm.xml文件,在屬性窗口中將其“Build Action”設置爲“Embedded Resource”(這是非常重要的一步,否則NHibernate將無法找到映射文件),如下:
 

build,ok,通過。

然後建立一個控制檯工程,命名爲Console1,添加NHibernate和上面Model項目的引用,另外添加一個應用程序配置文件,如下:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  
<configSections>
    
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System,
                    Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"
 />
  
</configSections>

  
<nhibernate>
    
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
    
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
    
<add key="hibernate.connection.connection_string" value="Server=localhost;Initial Catalog=NHibernate;Integrated Security=SSPI" />
    
<add key="hibernate.connection.isolation" value="ReadCommitted"/>
    
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
  
</nhibernate>

</configuration>


然後編寫如下代碼:

using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
using Test.Model;

namespace Console1
{
    
class Program
    
{
        
static void Main(string[] args)
        
{
            Configuration config 
= new Configuration().AddAssembly("Test.Model");
            ISessionFactory factory 
= config.BuildSessionFactory();
            ISession session 
= factory.OpenSession();

            Person person 
= new Person();
            person.Name 
= "Jackie Chan";

            ITransaction trans 
= session.BeginTransaction();
            
try
            
{
                session.Save(person);
                trans.Commit();
                Console.WriteLine(
"Insert Success!");
            }

            
catch (Exception ex)
            
{
                trans.Rollback();
                Console.WriteLine(ex.Message);
            }

        }

    }

}


運行,ok,執行成功!!
我們到數據庫檢查一下,如下:

 
我們想要添加的記錄已經成功加入到數據庫中!!
是不是感覺有些神奇啊?好,我們開始詳細解釋。
先來看生成的兩個文件,第一個是Person.cs,如下:

using System;
using System.Collections;

namespace Test.Model
{
    
Person
}


你可以發現,這完全是一個普通的poco類(Plain Old CLR Object),僅僅是對數據庫person表的一個完全映射,不依賴於任何框架,可以用來作爲持久化類,你可以在任何地方使用而不用擔心依賴於某些神祕的運行時東西。

另外,NHibernate需要知道怎樣去加載(load)和存儲(store)持久化類的對象。這正是NHibernate映射文件發揮作用的地方。映射文件告訴NHibernate它應該訪問數據庫(database)裏面的哪個表(table)及應該使用表裏面的哪些字段(column),這就是我們今天要講的重點了,Person.hbm.xml,如下:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
 
<class name="Test.Model.Person, Test.Model" table="Person">
  
<id name="Id" type="Int32" unsaved-value="0">
   
<column name="id" sql-type="int" not-null="true" unique="true" index="PK_Person"/>
   
<generator class="native" />
  
</id>
  
<property name="Name" type="String">
   
<column name="name" length="50" sql-type="varchar" not-null="true"/>
  
</property>
 
</class>
</hibernate-mapping>


不用說,最頂層的hibernate-mapping節點是NHibernate用來進行映射的根了,其中,包含一個class節點,裏面的name屬性對應我們的Person類,注意,需要完整的限定名;而table屬性,則顯而易見是對應數據庫中的Person表了。
我們再往裏面看,分別有兩個節點,一個是id,對應數據庫中的id,一個是屬性name,對應表中的column name和Person類中的name屬性,整個映射文件簡捷明瞭,一看即知。實際上這是由代碼產生工具產生的映射文件,裏面很多東西我們其實可以省略,如下寫法:
<property name=”Name” column=”name” />
NHibernate將自動去匹配數據庫中的列而不需要我們來設置。

下面,我們來看一下應用程序配置文件中都記錄了那些東西,如下:
hibernate.connection.provider_class  
定製IConnectionProvider的類型.
例如:full.classname.of.ConnectionProvider (如果提供者創建在NHibernate中), 或者 full.classname.of.ConnectionProvider, assembly (如果使用一個自定義的IConnectionProvider接口的實現,它不屬於NHibernate)。
 
hibernate.connection.driver_class  
定製IDriver的類型.
full.classname.of.Driver (如果驅動類創建在NHibernate中), 或者 full.classname.of.Driver, assembly (如果使用一個自定義IDriver接口的實現,它不屬於NHibernate)。

hibernate.connection.connection_string  
用來獲得連接的連接字符串.

hibernate.connection.isolation  
設置事務隔離級別. 請檢查 System.Data.IsolationLevel 來得到取值的具體意義並且查看數據庫文檔以確保級別是被支持的。
例如: Chaos, ReadCommitted, ReadUncommitted, RepeatableRead, Serializable, Unspecified

hibernate.dialect 
NHibernate方言(Dialect)的類名 - 可以讓NHibernate使用某些特定的數據庫平臺的特性
例如: full.classname.of.Dialect(如果方言創建在NHibernate中), 或者full.classname.of.Dialect, assembly (如果使用一個自定義的方言的實現,它不屬於NHibernate)。

接着,我們開始解釋代碼的執行,如下:

 

 

Configuration config = new Configuration().AddAssembly("Test.Model");

//通過配置對象來產生一個SessionFactory對象,這是一個Session工廠,
//那麼Session是用來幹什麼的呢?一個Session就是由NHibernate封裝
//的工作單元,我們可以近似地認爲它起到ADO.Net中Connection的作用。
ISessionFactory factory = config.BuildSessionFactory();
ISession session 
= factory.OpenSession();

Person person 
= new Person();
person.Name 
= "Jackie Chan";

//這裏,開啓一個由NHibernate封裝的事務,當然,在這裏最終代表
//的還是一個真實的數據庫事務,但是我們已經不需要再區分到底是
//一個SqlTransaction還是一個ODBCTransaction了
ITransaction trans = session.BeginTransaction();
try
{
    
//保存,提交,就這麼簡單!!
         session.Save(person);
        trans.Commit();
        Console.WriteLine(
"Insert Success!");
}

catch (Exception ex)
{
        trans.Rollback();
        Console.WriteLine(ex.Message);
}


現在有了一個基本的概念了吧??
好了,第一篇就講這麼多,我們下次再接着練習。

Step by Step,顧名思義,是一步一步來的意思,整個教程我將貫徹這一理念,待此係列結束後,我們再就某些高級話題進行深入。
任何建議或者批評,請e:[email protected]

posted on 2006-04-15 12:47 abluedog 閱讀(15592) 評論(157)  編輯 收藏 所屬分類: NHibernate

評論

#1樓  2006-04-15 13:17 csdn shit! [未註冊用戶]

寫點有新意的吧,拜託,太老套了!!!   回覆  引用  查看    

#2樓  2006-04-15 13:21 torome      

適合新手,不錯。   回覆  引用  查看    

#3樓  2006-04-15 13:22 皇帝的新裝      

給沒有接觸過的人看是有必要的。繼續努力。   回覆  引用  查看    

#4樓  2006-04-15 13:25 support [未註冊用戶]

多謝了,好鼕鼕   回覆  引用  查看    

#5樓  2006-04-15 13:26 福娃      

寫的很詳細,期待。。。   回覆  引用  查看    

#6樓  2006-04-15 13:33 Dflying Chen      

提一點建議,代碼的格式可以設置得好一點。   回覆  引用  查看    

#7樓  2006-04-15 14:10 福娃      

在net1.1上需要修改兩個地方
using System.Collections.Generic;
改爲
using System.Collections;
========================================
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System,
Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />

改成
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  回覆  引用  查看    

#8樓 [樓主] 2006-04-15 14:17 abluedog      

@福娃
實際上,在我上面的演示代碼裏其實也應該添加System.Collections引用的,因爲目前nhibernate官方還不支持generic,一個query對象返回的還是一個普通的IList。
第3方的nhibernate generic方案請參考:
http://www.ayende.com/projects/nhibernate-query-analyzer/generics.aspx   回覆  引用  查看    

#9樓  2006-04-15 14:23 劍在上海 [未註冊用戶]

挺!,之前還沒接觸過NHibernate,現在有點看懂了,感謝abluedog能花時間寫這麼好的教程   回覆  引用  查看    

#10樓 [樓主] 2006-04-15 17:24 abluedog      

除了Code Smith外,還有My Generation等代碼生成工具,都支持NHibernate文件的生成。
My Generation:http://www.mygenerationsoftware.com/portal/default.aspx
NHibernate Template:
http://www.mygenerationsoftware.com/phpBB2/viewtopic.php?t=1505   回覆  引用  查看    

#11樓  2006-04-15 22:27 mzl [未註冊用戶]

thankfulness!   回覆  引用  查看    

#12樓  2006-04-15 23:55 javac [未註冊用戶]

感謝abluedog,找了很久都沒找到這樣的入門級教程,其他教程像參考手冊,有點摸不着頭腦!
數據庫腳本在MS SQL 2000下沒有直接運行成功,手動建立後導出腳本如下:
CREATE TABLE [dbo].[Person] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Person] WITH NOCHECK ADD
CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED
(
[id]
) ON [PRIMARY]
GO
好像少了ALTER TABLE [dbo].[Person] WITH NOCHECK ADD,不知道是不是2000和2005版本上的差別?

還要感謝福娃指出.net1.1上代碼需要修改的地方!

繼續期待後面的教程!   回覆  引用  查看    

#13樓  2006-04-17 10:26 a11s.net      

非常適合我,收藏了   回覆  引用  查看    

#14樓  2006-04-17 22:16 卡卡.net      

Nhibernate.org一直不能訪問,哪位網友提供NHibernate的下載地址?感謝。   回覆  引用  查看    

#15樓  2006-05-23 10:34 karlsoft      

VS2005和SQLServer2005正版哪裏有下﹐哪位有﹐共享一下。謝謝。   回覆  引用  查看    

#16樓  2006-05-23 10:34 karlsoft      

VS2005和SQLServer2005正版哪裏有下﹐哪位有﹐共享一下。謝謝。   回覆  引用  查看    

#17樓  2006-05-25 12:06 karlsoft      

使用NHibernate在Web層在按鈕下實現這個﹐不能添加數據﹐請問什麼原因﹐是不是配置文件有問題﹐在web.config中已經加了這個
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System,Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />

</configSections>
也加了這個
<nhibernate>
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect"/>
<add key="hibernate.connection.connection_string" value="server=MIS03;uid=sa;pwd=;"/>
</nhibernate>
我的代碼碼如下﹕
按鈕下實現如下:

Configuration cfg = new Configuration();
cfg.AddAssembly("GuestBook.Data");
ISessionFactory f = cfg.BuildSessionFactory();
ISession s = f.OpenSession();
ITransaction t = s.BeginTransaction();
Users newUser = new Users();
newUser.Name = "papersnake";
newUser.Password = "123456";
newUser.Email = "[email protected]";
newUser.RegTime = DateTime.Now;
s.Save(newUser);
t.Commit();
s.Close();   回覆  引用  查看    

#18樓  2006-06-13 14:43 感謝樓主 [未註冊用戶]

好東西,很適合入門,謝謝樓主!   回覆  引用  查看    

#19樓  2006-06-21 09:54 main      

應@karlsoft
應該檢查下你的版本,1.2.0那個的,感覺和之前的差別蠻大。   回覆  引用  查看    

#20樓  2006-07-14 17:33 USAF      

SQL Server用Code Smith生成Person.cs和Person.hbm.xml;如果MySQL數據庫用什麼工具可以生成呢? 點樣生成?   回覆  引用  查看    

#21樓  2006-07-15 23:03 零度海洋      

推薦一個學習.NET的好站點..
http://www.zero163.com/sortinfo.asp?Classid=45

asp.net2.0 最新最全的資料
各類.net三方控件..   回覆  引用  查看    

#22樓  2006-08-24 10:05 小草      

很好,正好想了解這方面的,我補充了一下在Oralce數據庫的操作,有興趣可以查看我的blogs : http://www.cnblogs.com/liubiqu/archive/2006/08/24/485016.html   回覆  引用  查看    

#23樓  2006-08-25 17:54 viptell [未註冊用戶]

學習了,已經在vs2005 sql2000通過,明天接着下一課,謝謝老是,寫的很明白!   回覆  引用  查看    

#24樓  2006-08-30 16:45 kegogo      

感謝abluedog,請教一個問題,有點摸不着頭腦!
我照着你的方法去做,卻發現老是報錯,後經調查我發現原來是,竟然是nhibernate中有一個錯誤,那就是它要對屬性成成的方法要判斷它是否是Virtual如下:
在ProxyTypeValidator頁下的CheckEveryPublicMemberIsVirtual方法它要檢查所有公共的方法是否是Virtual,而檢查屬性則報錯,請問這裏爲什麼要進行這樣檢查,有什麼好的解決方法嗎?   回覆  引用  查看    

#25樓  2006-09-13 14:43 zhongge [未註冊用戶]

to kegogo

你用的是1.2.0版本的NHibernate.dll
摟住用的是1.0.2的   回覆  引用  查看    

#26樓  2006-09-13 14:45 zhongge [未註冊用戶]

辛苦摟住了,希望能跟大家一起探尋Nhibernate的本質的東東:)   回覆  引用  查看    

#27樓  2006-09-18 11:41 turnright [未註冊用戶]

我也是遇到和kegogo一樣的問題,用1.0.2就ok了,如果用1.2.0應該怎麼改呢?
  回覆  引用  查看    

#28樓  2006-10-09 09:35 bluepig [未註冊用戶]

我剛開始接觸NHiberate,樓主文章寫道淺簡易懂,支持支持!   回覆  引用  查看    

#29樓  2006-10-09 16:37 anmyan [未註冊用戶]

運行時出現這個錯誤是不是配置文件有什麼問題啊
D:/AnStudy/Nhibtest/Nhibtest/obj/Debug/CSCA4.tmp Error generating Win32 resource: Error reading icon 'D:/AnStudy/Nhibtest/Nhibtest/App.config' -- データが無効です。
我的配置文件爲

<configuration>
<configSections>
<section name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System,
Version=1.0.3300.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<nhibernate>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<add key="hibernate.connection.isolation" value="ReadCommitted" />
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />

<add key="hibernate.connection.connection_string" value="server=test;uid=sa;pwd=;"/>
<add key="hibernate.cache.provider_class" value="NHibernate.Caches.SysCache.SysCacheProvider,NHibernate.Caches.SysCache" />
</nhibernate>
</configuration>   回覆  引用  查看    

#30樓  2006-10-17 15:03 xuexi [未註冊用戶]

你第三個圖的class中outputdriectory 後面的字符串是什麼啊?求?代表什麼意思啊?   回覆  引用  查看    

#31樓  2006-10-24 09:09 lwei [未註冊用戶]

能否詳細介紹一下Code Smith ??   回覆  引用  查看    

#32樓  2006-10-30 11:30 風吹河岸柳輕揚      

很不錯,樓主加油   回覆  引用  查看    

#33樓  2006-11-25 15:40 IT獵人      

哦,我知道了,原來是Server=localhost的問題,改爲Server=(local)就可以了,另外連接超時的默認值是30秒,所以那裏沒有馬上拋出異常,是我沒有耐心等它個30秒,呵呵.
  回覆  引用  查看    

#34樓  2006-11-29 16:36 9527 [未註冊用戶]

我是新手,爲什麼我照做的時候報錯:
我Win2003,.net2.0 ,vs2005, sql2005,NHibernate.dll(1.0.2.0),CodeSmith4.0.0
報錯的位置是:
Configuration config = new Configuration().AddAssembly("Test.Model");

An unhandled exception of type 'System.TypeInitializationException' occurred in Console1.exe

Additional information: The type initializer for 'NHibernate.Cfg.Configuration' threw an exception.   回覆  引用  查看    

#35樓  2007-01-20 01:02 iafpdael [未註冊用戶]

<a href="http://wfneoodu.com">pltlgmoi</a> [URL=http://zlofrpjs.com]blbvyacb[/URL] mxpslzuh http://sdlbhnax.com xuiswqlw vuccniwo   回覆  引用  查看    

#36樓  2007-01-20 03:01 rcgqzrdu [未註冊用戶]

[URL=http://cryfjhre.com]iwwpuplx[/URL] wjnhsyle http://sgqttdce.com pzurfmeu jbbzfaei <a href="http://mbfjwcqy.com">yfsnhwgw</a>   回覆  引用  查看    

#37樓  2007-01-21 02:17 pharmacy [未註冊用戶]

Nothing changes your opinion of a friend so surely as success - yours or his.   回覆  引用  查看    

#38樓  2007-01-21 04:26 paxil [未註冊用戶]

If you want creative workers, give them enough time to play.   回覆  引用  查看    

#39樓  2007-01-21 05:48 ultram [未註冊用戶]

Fiction is obliged to stick to possibilities. Truth isn't.   回覆  引用  查看    

#40樓  2007-01-21 07:52 buy cialis online [未註冊用戶]

Let not the sands of time get in your lunch.   回覆  引用  查看    

#41樓  2007-01-21 09:03 cheap viagra lathy pretermission [未註冊用戶]

Sometimes love will pick you up by the short hairs...and jerk the heck out of you.   回覆  引用  查看    

#42樓  2007-01-21 11:49 paxil [未註冊用戶]

We play the hands of cards life gives us. And the worst hands can make us the best players.   回覆  引用  查看    

#43樓  2007-01-21 14:28 nexium [未註冊用戶]

Under democracy one party always devotes its chief energies to trying to prove that the other party is unfit to rule - and both commonly succeed, and are right.   回覆  引用  查看    

#44樓  2007-01-21 15:24 hoodia [未註冊用戶]

We inhereit from our ancestors gifts so often taken for granted... Each of us contains within... this inheritance of soul. We are links between the ages, containing past and present expectations, sacred memories and future promise.   回覆  引用  查看    

#45樓  2007-01-21 17:53 buy cialis online [未註冊用戶]

My theology, briefly, is that the universe was dictated but not signed.   回覆  引用  查看    

#46樓  2007-01-21 20:41 buy adipex [未註冊用戶]

I am doomed to an eternity of compulsive work. No set goal achieved satisfies. Success only breeds a new goal. The golden apple devoured has seeds. It is endless.   回覆  引用  查看    

#47樓  2007-01-21 23:24 levitra [未註冊用戶]

Nothing in the world can take the place of Persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. The slogan 'Press On' has solved and always will solve the problems of the human race.   回覆  引用  查看    

#48樓  2007-01-22 00:20 tramadol [未註冊用戶]

There is an alchemy in sorrow. It can be transmuted into wisdom, which, if it does not bring joy, can yet bring happiness.   回覆  引用  查看    

#49樓  2007-01-22 00:29 diet [未註冊用戶]

We succeed only as we identify in life, or in war, or in anything else, a single overriding objective, and make all other considerations bend to that one objective.   回覆  引用  查看    

#50樓  2007-01-22 04:24 zdnqeghr [未註冊用戶]

<a href="http://sqszzzjj.com">dlngopps</a> ovxeltdj http://hpsivamv.com qufadbaj mifxasur [URL=http://tavoojdk.com]ubzqpmkz[/URL]   回覆  引用  查看    

#51樓  2007-01-22 07:00 ghpyyicu [未註冊用戶]

[URL=http://onjlrjuu.com]yvuvnwjg[/URL] gajlyqdb http://lsngfutm.com rwemxlyf ibeusysg <a href="http://kcvdqmtf.com">dnuuebap</a>   回覆  引用  查看    

#52樓  2007-01-22 08:33 xgjhkjvf [未註冊用戶]

wzsmkfns http://krgaoojl.com kwtbzkun qvdmcxum [URL=http://pxyqsdih.com]yncyqoqm[/URL] <a href="http://wycczfvk.com">bjjpskjk</a>   回覆  引用  查看    

#53樓  2007-01-22 10:34 dozsnceb [未註冊用戶]

[URL=http://pomghsev.com]rqhertnp[/URL] <a href="http://wcwrdtii.com">bzotjyam</a> nmdzqxud http://wanxabvk.com yfzwuxjf xaznldqi   回覆  引用  查看    

#54樓  2007-01-22 14:57 diet [未註冊用戶]

There are several good protections against temptations, but the surest is cowardice.   回覆  引用  查看    

#55樓  2007-01-22 16:27 buy levitra [未註冊用戶]

I've been on a diet for two weeks and all I've lost is two weeks.   回覆  引用  查看    

#56樓  2007-01-22 16:50 wkedfnly [未註冊用戶]

<a href="http://ubeouopw.com">bowvdwrd</a> [URL=http://idcqzxjg.com]oreanqbj[/URL] savckuyw http://nuztttds.com ejzjotuz rxzcjpjl   回覆  引用  查看    

#57樓  2007-01-22 20:14 diet [未註冊用戶]

Life is a great big canvas; throw all the paint on it you can.   回覆  引用  查看    

#58樓  2007-01-22 20:24 carisoprodol [未註冊用戶]

Love truth, and pardon error.   回覆  引用  查看    

#59樓  2007-01-22 23:45 adipex [未註冊用戶]

No great improvements in the lot of mankind are possible until a great change takes place in the fundamental constitution of their modes of thought.   回覆  引用  查看    

#60樓  2007-01-23 02:24 zyrtec [未註冊用戶]

The reason why worry kills more people than work is that more people worry than work.   回覆  引用  查看    

#61樓  2007-01-23 04:03 zchtgaqi [未註冊用戶]

[URL=http://zwoslryl.com]duttqprk[/URL] qjtkmyxq http://nfjoiqbe.com xtpslide oxxpxbyq <a href="http://hmjakquo.com">frvujuly</a>   回覆  引用  查看    

#62樓  2007-01-24 05:19 dilmdlwd [未註冊用戶]

krscngdw http://oikemwjm.com zdavylxi vpfvkkhm <a href="http://tnuosjar.com">fntfbuxu</a> [URL=http://tayqaxse.com]jxzqjszg[/URL]   回覆  引用  查看    

#63樓  2007-01-25 02:51 yngyzvpi [未註冊用戶]

[URL=http://mkkbxrrm.com]ofzzlonv[/URL] <a href="http://oyujxhwt.com">aciisevg</a> salpknkw http://mlpqajws.com ueooeesu hhusixil   回覆  引用  查看    

#64樓  2007-01-26 04:09 buy tramadol [未註冊用戶]

Insanity in individuals is something rare - but in groups, parties, nations and epochs, it is the rule.   回覆  引用  查看    

#65樓  2007-01-26 07:49 vicodin [未註冊用戶]

Nothing is said that has not been said before.   回覆  引用  查看    

#66樓  2007-01-26 08:09 ultram [未註冊用戶]

There is still a difference between something and nothing, but it is purely geometrical and there is nothing behind the geometry.   回覆  引用  查看    

#67樓  2007-01-26 11:21 fitness [未註冊用戶]

Nothing is more conducive to peace of mind than not having any opinions at all.   回覆  引用  查看    

#68樓  2007-01-26 11:35 tramadol online [未註冊用戶]

Realize that true happiness lies within you. Waste no time and effort searching for peace and contentment and joy in the world outside. Remember that there is no happiness in having or in getting, but only in giving. Reach out. Share. Smile. Hug. Happiness is a perfume you cannot pour on others without getting a few drops on yourself.   回覆  引用  查看    

#69樓  2007-01-26 15:15 ultram [未註冊用戶]

Paradise is exactly like where you are right now... only much, much better.   回覆  引用  查看    

#70樓  2007-01-26 19:31 ambien [未註冊用戶]

I was gratified to be able to answer promptly. I said I don't know.   回覆  引用  查看    

#71樓  2007-01-26 23:03 order cialis [未註冊用戶]

When we got into office, the thing that surprised me the most was that things were as bad as we'd been saying they were.   回覆  引用  查看    

#72樓  2007-01-29 09:57 hebpjysy [未註冊用戶]

<a href="http://bkyjkojv.com">mmogwncg</a> cuiqjfuw http://ujwumzap.com wlzzakxu iklsljqy [URL=http://htomefbn.com]yrdzfogu[/URL]   回覆  引用  查看    

#73樓  2007-01-29 11:51 drug [未註冊用戶]

Men are equal; it is not birth but virtue that makes the difference.   回覆  引用  查看    

#74樓  2007-01-29 15:45 buy cialis online [未註冊用戶]

Normal is not something to aspire to, it's something to get away from.   回覆  引用  查看    

#75樓  2007-01-29 21:08 buy meridia [未註冊用戶]

Never make a defense or an apology until you are accused.   回覆  引用  查看    

#76樓  2007-01-30 00:39 south beach diet [未註冊用戶]

Never rely on the glory of the morning nor the smiles of your mother-in-law.   回覆  引用  查看    

#77樓  2007-01-30 04:48 propecia [未註冊用戶]

You can't wait for inspiration. You have to go after it with a club.   回覆  引用  查看    

#78樓  2007-01-30 08:35 tramadol [未註冊用戶]

I say luck is when an opportunity comes along, and you're prepared for it.   回覆  引用  查看    

#79樓  2007-01-30 11:56 buy soma [未註冊用戶]

Because we don't think about future generations, they will never forget us.   回覆  引用  查看    

#80樓  2007-01-30 15:29 vicodin [未註冊用戶]

To be nobody but yourself in a world which is doing its best day and night to make you like everybody else means to fight the hardest battle which any human being can fight and never stop fighting.   回覆  引用  查看    

#81樓  2007-01-30 19:02 ambien [未註冊用戶]

I feel very strongly that change is good because it stirs up the system.   回覆  引用  查看    

#82樓  2007-01-30 22:35 lipitor [未註冊用戶]

Be careful that victories do not carry the seed of future defeats.   回覆  引用  查看    

#83樓  2007-01-31 01:50 cialis online [未註冊用戶]

Depend not on another, but lean instead on thyself...True happiness is born of self-reliance.   回覆  引用  查看    

#84樓  2007-01-31 05:16 vitamin [未註冊用戶]

A boy can learn a lot from a dog: obedience, loyalty, and the importance of turning around three times before lying down.   回覆  引用  查看    

#85樓  2007-01-31 08:54 celexa [未註冊用戶]

It is not always the same thing to be a good man and a good citizen.   回覆  引用  查看    

#86樓  2007-01-31 12:35 ultram [未註冊用戶]

I have often wished I had time to cultivate modesty... But I am too busy thinking about myself.   回覆  引用  查看    

#87樓  2007-01-31 16:49 paxil cr [未註冊用戶]

Someone's boring me. I think it's me.   回覆  引用  查看    

#88樓  2007-01-31 20:25 xanax [未註冊用戶]

The great art of giving consists in this: the gift should cost very little and yet be greatly coveted, so that it may be the more highly appreciated.   回覆  引用  查看    

#89樓  2007-02-01 00:03 nexium [未註冊用戶]

Refuse to be ill. Never tell people you are ill; never own it to yourself. Illness is one of those things which a man should resist on principle.   回覆  引用  查看    

#90樓  2007-02-01 03:57 vicodin vicianose curassow [未註冊用戶]

Happiness lies in the joy of achievement and the thrill of creative effort.   回覆  引用  查看    

#91樓  2007-02-01 07:44 diabetes [未註冊用戶]

Late to bed and late to wake will keep you long on money and short on mistakes.   回覆  引用  查看    

#92樓  2007-02-01 12:07 celebrex [未註冊用戶]

Nothing in the world can take the place of Persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. The slogan 'Press On' has solved and always will solve the problems of the human race.   回覆  引用  查看    

#93樓  2007-02-01 12:08 hydrocodone micropipet haemoglobin [未註冊用戶]

Summer afternoon - Summer afternoon... the two most beautiful words in the English language.   回覆  引用  查看    

#94樓  2007-02-01 15:49 pharmacy [未註冊用戶]

Never let the demands of tomorrow interfere with the pleasures and excitement of today.   回覆  引用  查看    

#95樓  2007-02-01 20:39 gxonmsgp [未註冊用戶]

<a href="http://lmjoxhly.com">sptxikpn</a> ialqbrjl http://kbatyvzq.com snbkazcw kkibtkik [URL=http://cwrofzbz.com]fvnapiig[/URL]   回覆  引用  查看    

#96樓  2007-02-02 07:39 buy valium [未註冊用戶]

Curiosity killed the cat, but for a while I was a suspect.   回覆  引用  查看    

#97樓  2007-02-02 11:16 carisoprodol online [未註冊用戶]

Exercise ferments the humors, casts them into their proper channels, throws off redundancies, and helps nature in those secret distributions, without which the body cannot subsist in its vigor, nor the soul act with cheerfulness.   回覆  引用  查看    

#98樓  2007-02-02 15:26 vicodin without a prescription [未註冊用戶]

The supreme irony of life is that hardly anyone gets out of it alive.   回覆  引用  查看    

#99樓  2007-02-02 19:48 order cialis [未註冊用戶]

Real love is a permanently self-enlarging experience.   回覆  引用  查看    

#100樓  2007-02-03 00:47 fvvfuwiv [未註冊用戶]

gpwrdahu http://usdvblai.com suvwkpop domvtfkz [URL=http://jcshnlix.com]vozljdyb[/URL] <a href="http://fmlhjtqu.com">clejoppf</a>   回覆  引用  查看    

#101樓  2007-02-03 12:01 prescription diet pills [未註冊用戶]

Absolute faith corrupts as absolutely as absolute power.   回覆  引用  查看    

#102樓  2007-02-04 11:02 wuvqmvjx [未註冊用戶]

vhntgoye http://hqabrlhp.com pwqzoasy ocutxwkn <a href="http://mtrpcsmo.com">hsvbqyyn</a> [URL=http://dtpvyhfp.com]ujvpetrz[/URL]   回覆  引用  查看    

#103樓  2007-02-04 18:07 levitra buy [未註冊用戶]

People fail forward to success.   回覆  引用  查看    

#104樓  2007-02-04 21:19 cheap viagra [未註冊用戶]

A little government and a little luck are necessary in life, but only a fool trusts either of them.   回覆  引用  查看    

#105樓  2007-02-05 03:35 lipitor [未註冊用戶]

The scornful nostril and the high head gather not the odors that lie on the track of truth.   回覆  引用  查看    

#106樓  2007-02-05 06:57 weight loss [未註冊用戶]

The Past is to be respected and acknoledged, but not to be worshiped. It is our future in which we will find our greatness.   回覆  引用  查看    

#107樓  2007-02-05 17:46 kpqjnnsz [未註冊用戶]

<a href="http://rvmudfdm.com">zboovdyf</a> qlaopujn http://lhwbtlgd.com cbvduwkh gqestdka [URL=http://izyyqeow.com]qlmacylr[/URL]   回覆  引用  查看    

#108樓  2007-02-06 00:11 vicodin without a prescription [未註冊用戶]

I don't own a cell phone or a pager. I just hang around everyone I know, all the time. If someone wants to get a hold of me, they just say 'Mitch,' and I say 'what?' and turn my head slightly.   回覆  引用  查看    

#109樓  2007-02-06 05:10 buy soma [未註冊用戶]

God creates men, but they choose each other.   回覆  引用  查看    

#110樓  2007-02-06 09:14 cialis online [未註冊用戶]

Whatever you do, do it to the purpose; do it thoroughly, not superficially. Go to the bottom of things. Any thing half done, or half known, is in my mind, neither done nor known at all. Nay, worse, for it often misleads.   回覆  引用  查看    

#111樓  2007-02-06 13:15 drug abirritation reachless [未註冊用戶]

Life is divided into the horrible and the miserable.   回覆  引用  查看    

#112樓  2007-02-06 21:41 fioricet online [未註冊用戶]

Americans are benevolently ignorant about Canada, while Canadians are malevolently well informed about the United States.   回覆  引用  查看    

#113樓  2007-02-07 01:30 hydrocodone [未註冊用戶]

Few people think more than two or three times a year; I have made an international reputation for myself by thinking once or twice a week.   回覆  引用  查看    

#114樓  2007-02-07 01:31 hydrocodone [未註冊用戶]

Few people think more than two or three times a year; I have made an international reputation for myself by thinking once or twice a week.   回覆  引用  查看    

#115樓  2007-02-08 13:18 soma [未註冊用戶]

Censorship, like charity, should begin at home; but, unlike charity, it should end there.   回覆  引用  查看    

#116樓  2007-02-09 08:20 giuwwgqu [未註冊用戶]

geixeosv http://lxtdhbox.com gjcwmoab rwnmopaz [URL=http://nybccvlx.com]pzdiwwkz[/URL] <a href="http://rctcmsyw.com">wnsbwebq</a>   回覆  引用  查看    

#117樓  2007-02-09 09:24 valium [未註冊用戶]

As I get older, I've learned to listen to people rather than accuse them of things.   回覆  引用  查看    

#118樓  2007-02-09 13:19 buy carisoprodol [未註冊用戶]

I like coincidences. They make me wonder about destiny, and whether free will is an illusion or just a matter of perspective. They let me speculate on the idea of some master plan that, from time to time, we're allowed to see out of the corner of our eye.   回覆  引用  查看    

#119樓  2007-02-09 18:38 hydrocodone [未註冊用戶]

Sometimes love will pick you up by the short hairs...and jerk the heck out of you.   回覆  引用  查看    

#120樓  2007-02-09 23:04 buy xanax online [未註冊用戶]

O, it is excellent to have a giant's strength; but it is tyrannous to use it like a giant.   回覆  引用  查看    

#121樓  2007-02-10 03:38 diet pill phentermine [未註冊用戶]

Love is the triumph of imagination over intelligence.   回覆  引用  查看    

#122樓  2007-02-10 07:03 hydrocodone online [未註冊用戶]

You know what's interesting about Washington? It's the kind of place where second-guessing has become second nature.   回覆  引用  查看    

#123樓  2007-02-10 10:41 buy meridia [未註冊用戶]

Famous remarks are very seldom quoted correctly.   回覆  引用  查看    

#124樓  2007-02-10 14:31 lipitor [未註冊用戶]

He will always be a slave who does not know how to live upon a little.   回覆  引用  查看    

#125樓  2007-02-11 02:41 idsbdivx [未註冊用戶]

akdxgpvr http://hfhmyusx.com dmvirrig sonqmtyw <a href="http://fsbnnsjz.com">woadgbdi</a> [URL=http://ygbgbozm.com]awfqazph[/URL]   回覆  引用  查看    

#126樓  2007-03-04 07:31 buy xanax online [未註冊用戶]

A smiling face is half the meal.   回覆  引用  查看    

#127樓  2007-03-04 11:30 drug [未註冊用戶]

There is no stigma attached to recognizing a bad decision in time to install a better one.   回覆  引用  查看    

#128樓  2007-03-06 14:22 eeykvhdf [未註冊用戶]

kcpiiiyz http://qtlyuxoq.com nukozzyh bckrypbx <a href="http://jgqxngjz.com">wbywewuv</a> [URL=http://vnzvgkeo.com]nwiuxytl[/URL]   回覆  引用  查看    

#129樓  2007-03-06 15:43 adipex [未註冊用戶]

The world tolerates conceit from those who are successful, but not from anybody else.   回覆  引用  查看    

#130樓  2007-03-06 19:05 buy xanax on line preemptive correct [未註冊用戶]

It is better to have loved and lost than never to have lost at all.   回覆  引用  查看    

#131樓  2007-03-18 21:57 ggww [未註冊用戶]

請問一個問題。我按照你的本個教程,建立控制檯工程的時候報錯了。就是“然後建立一個控制檯工程,命名爲Console1,添加NHibernate和上面Model項目的引用,另外添加一個應用程序配置文件”這裏的時候vs2005報錯了。

我在這個控制檯工程中,新建了一個應用程序配置文件(application configuration file)。我拷貝了你的配置文件的內容的時候:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System,
Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
</configuration>
添加到上面的代碼,沒有問題。
就是添加:
<nhibernate>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<add key="hibernate.connection.connection_string" value="Server=localhost;Initial Catalog=NHibernate;Integrated Security=SSPI" />
<add key="hibernate.connection.isolation" value="ReadCommitted"/>
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
</nhibernate>
的時候vs2005報錯:
Message 1 Could not find schema information for the element 'nhibernate'. D:/NHibernate_projects/Model/Console1/Console1/App.config 7 4 Console1
Message 2 Could not find schema information for the element 'add'. D:/NHibernate_projects/Model/Console1/Console1/App.config 8 6 Console1
Message 3 Could not find schema information for the attribute 'key'. D:/NHibernate_projects/Model/Console1/Console1/App.config 8 10 Console1
一共有16個錯誤。

請問這個問題如何解決??????多謝。   回覆  引用  查看    

#132樓  2007-03-26 09:13 levitra [未註冊用戶]

Joy is prayer - Joy is strength - Joy is love - Joy is a net of love by which you can catch souls.   回覆  引用  查看    

#133樓  2007-03-26 13:14 buy valium online [未註冊用戶]

Nothing is as certain as that the vices of leisure are gotten rid of by being busy.   回覆  引用  查看    

#134樓  2007-03-26 17:34 diet pills [未註冊用戶]

Good habits, which bring our lower passions and appetites under automatic control, leave our natures free to explore the larger experiences of life.   回覆  引用  查看    

#135樓  2007-03-27 00:38 oxnotoza [未註冊用戶]

<a href="http://vnjlvdaf.com">lmdbszpb</a> [URL=http://lsthijeq.com]gxfczjmv[/URL] ildbursl http://aeufcpas.com ireppczp jseyxxfb   回覆  引用  查看    

#136樓  2007-03-28 10:04 cxq [未註冊用戶]

按照你的步驟做
Configuration config = new Configuration().AddAssembly("Test.Model");
這一句出錯
提示: Test.Model.Person.hbm.xml(2,2): XML validation error: 未能找到元素“urn:nhibernate-mapping-2.0:hibernate-mapping”的架構信息。

這是什麼原因??
我用的是nhibernate 1.2 的版本   回覆  引用  查看    

#137樓  2007-03-28 10:08 cxq [未註冊用戶]

我是新手
請問:
Console1 的應用配置文件 的 文件名 是什麼??
這一步能不能說的詳細點.
  回覆  引用  查看    

#138樓  2007-03-29 17:36 price viagra [未註冊用戶]

The average person thinks he isn't.   回覆  引用  查看    

#139樓  2007-03-31 04:21 propecia [未註冊用戶]

Nothing inspires forgiveness quite like revenge.   回覆  引用  查看    

#140樓  2007-03-31 13:21 [email protected] [未註冊用戶]

按照你的步驟做
Configuration config = new Configuration().AddAssembly("Test.Model");
這一句出錯
提示: Test.Model.Person.hbm.xml(2,2): XML validation error: 未能找到元素“urn:nhibernate-mapping-2.0:hibernate-mapping”的架構信息。

解決方法:修改Test.Model.Person.hbm.xml中“urn:nhibernate-mapping-2.0”爲“urn:nhibernate-mapping-2.2”
修改Test.Model.Person.cs爲:
public virtual int Id
{
get {return _id;}
set {_id = value;}
}

public virtual string Name
{
get { return _name; }
set
{
if ( value != null && value.Length > 50)
throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
_name = value;
}
}   回覆  引用  查看    

#141樓  2007-04-20 16:01 steven [未註冊用戶]

怎麼調試不通,第一句話就報錯!

未處理 System.TypeInitializationException
Message="“NHibernate.Cfg.Configuration”的類型初始值設定項引發異常。"
Source="NHibernate"
TypeName="NHibernate.Cfg.Configuration"
StackTrace:
在 NHibernate.Cfg.Configuration..ctor()
在 Console1.Program.Main(String[] args) 位置 D:/Console1/Console1/Program.cs:行號 17
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
  回覆  引用  查看    

#142樓  2007-04-20 16:02 steven [未註冊用戶]

樓主還是把源碼發佈出來吧!!!   回覆  引用  查看    

#143樓  2007-05-09 17:16 jyorin [未註冊用戶]

按你的方法做,前面都沒問題,運行時:
Unknown entity class: Test.Model.Person   回覆  引用  查看    

#144樓  2007-05-09 17:28 jyorin [未註冊用戶]

OK,問題已解決!   回覆  引用  查看    

#145樓  2007-06-22 22:41 梅梅 [未註冊用戶]

這個工程類庫在那裏建.....
新建立一個類庫工程,爲了簡潔起見,我們命名爲Model,需要注意的是,爲了跟剛纔生成的文件對應,我們需要在Model工程的屬性頁中將起Assembly名字設爲上面的“Test.Model   回覆  引用  查看    

#146樓  2007-06-28 12:50 路過 [未註冊用戶]

按照摟住的步驟做下來,調試時總是在Configuration config = new Configuration().AddAssembly("Test.Model");報xml錯誤。
後來引入了xsd文件才發現,原來用CodeSmith生成的Person.hbm.xml文件中的破折號(-)被替換成了下劃線(_),修改過來運行就可以了。

  回覆  引用  查看    

#147樓 [TrackBack] 2007-07-15 13:35 大冰

NHibernateStepbyStep(一)Hello,NHibernate! NHibernateStepbyStep(一)
[引用提示]大冰引用了該文章, 地址: http://www.cnblogs.com/hanbing768/archive/2007/07/15/818677.html   回覆  引用  查看    

#148樓 [TrackBack] 2007-07-24 17:13 MichaeL

摘要:這幾天開始學習.Net下的企業級應用相關的工具和開源項目。以其從中吸取和借鑑好的思想,同時也能夠將其應用在項目開發中。今天有幸收集到了幾篇有關Nhibernate的教程,特轉載到自己的博客中,以免以後再去查找。
[引用提示]MichaeL引用了該文章, 地址: http://www.cnblogs.com/MichaelLu/archive/2007/07/24/829680.html   回覆  引用  查看    

#149樓  2007-08-20 14:39 king [未註冊用戶]

請問,是如何解決的 我也遇到了同樣的問題@jyorin
  回覆  引用  查看    

#150樓  2007-09-12 16:50 傑客      

你好,我也是這個錯誤。不知如何解決@jyorin
  回覆  引用  查看    

#151樓  2007-10-19 10:51 ant520      

csdn shit!
你這種人,只會說,你有本事自己去寫,牛B個撒子喲,老套,我還剛開始學了   回覆  引用  查看    

#152樓  2007-11-23 16:55 iliuda [未註冊用戶]

強烈支持,十分感謝   回覆  引用  查看    

#153樓  2007-12-20 15:45 Lim [未註冊用戶]

一樓傻 B   回覆  引用  查看    

#154樓  2008-01-07 13:24 cgx898      

運行到第二行時出現在錯誤,提示信息爲:NHibernate.InvalidProxyTypeException was unhandled
Message="The following types may not be used as proxies:/nTest.Model.Person: method set_Id should be virtual/nTest.Model.Person: method get_Name should be virtual/nTest.Model.Person: method set_Name should be virtual/nTest.Model.Person: method get_Id should be virtual"
Source="NHibernate"
StackTrace:
在 NHibernate.Cfg.Configuration.Validate()
在 NHibernate.Cfg.Configuration.BuildSessionFactory()
在 Console1.Program.Main(String[] args) 位置 E:/Download/數據持久層ORM/Model/Console1/Console1/Program.cs:行號 16
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
  回覆  引用  查看    

#155樓  2008-03-25 11:27 Enno [未註冊用戶]

@csdn shit!
NHibernate Step by Step (一) Hello,NHibernate!
這纔是第一課呢

新手看,好啊   回覆  引用  查看    

#156樓  2008-03-26 13:30 老志      

看完..
按照140樓 [email protected] 所提的方法修正
運行正常
使用版本 -> NHibernate-1.2.1.GA

請問如何將文章引用到自己的部落格裡
感恩
  回覆  引用  查看    

#157樓  2008-04-14 09:56 tangzhen [未註冊用戶]

小弟在createQuery時遇到了問題:我的數據庫的表是以用戶名加前綴來構建的(例如:有用戶dy,那表就時dy.USER 表);所以我寫了個createQuery(" from dy.USER as a WHERE a.ID=1 "); 這時會報錯誤: undefined alias or unknown mapping: dy [ from dy.USER as a WHERE a.ID=1 ] ;其它的save等操作正常. 是不是我這樣建的表名在createquery時 他的語法檢測機制把表名的前綴看做是別名了?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章