惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
博客园 - 三生石上(FineUI控件)
V
V2EX
有赞技术团队
有赞技术团队
V
Visual Studio Blog
小众软件
小众软件
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
量子位
T
Tailwind CSS Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Palo Alto Networks Blog
Cisco Talos Blog
Cisco Talos Blog
I
Intezer
Project Zero
Project Zero
A
Arctic Wolf
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
L
Lohrmann on Cybersecurity
S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Tor Project blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Security @ Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
L
LINUX DO - 热门话题
G
GRAHAM CLULEY
Help Net Security
Help Net Security
N
News | PayPal Newsroom
W
WeLiveSecurity
G
Google Developers Blog
Microsoft Security Blog
Microsoft Security Blog
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
C
Check Point Blog

博客园 - 旭日东生

微软项目开发团队每个角色的一天是如何度过的【转】 如何对软件项目团队成员进行角色和岗位的划分【转】 C# 委托的妙文【转】 NHibernate初体验[转] 软件系统与管理工作的执行、监督问题 面向对象设计的一些个人认知阶段性总结 代码编码规则检查工具Microsoft StyleCop 4.2 [转]为什么用例不是“功能”? ms-sql递归调用 有关数据完整性的教训和转一篇文章 转《马云和爱迪生:究竟谁“欺骗了世界”》以及我的个人想法 转而告之:马云给雅虎员工作的精彩演讲:爱迪生欺骗了世界! 哈佛管理论丛:谁背上了令人讨厌的猴子 有关UP(unified process)的疑问和胡思乱想 关于《敏捷软件开发:原则、模式与实践(C#版)》 更新数据库所有表的某一个指定字段 功能自动化测试工具列表大全【转】 企业内部实现软件测试自动化的方案探讨 一些有用Transat-SQL技巧 [持续更新中]
配置NHibernate有三种常见的配置方法[转] - 旭日东生 - 博客园
旭日东生 · 2008-08-27 · via 博客园 - 旭日东生

配置NHibernate有三种常见的配置方法。
  1:在web.config,App.config里面配置

<?xml version="1.0" encoding="utf-8" ?> <configuration> <!-- Add this element --> <configSections> <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /> </configSections> <!-- Add this element --> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="connection.connection_string">Server=TLSZ207\SQLEXPRESS;initial catalog=Test;Integrated Security=true</property> </session-factory> </hibernate-configuration> <!-- Leave the system.web section unchanged --> <system.web> </system.web> </configuration>

  则需要这样实例化Configuration对象。
  NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
  这种配置方法将会到应用程序配置文件(App.Config,Web.Config)中查找NHibernate的配置信息.

  2:hibernate.cfg.xml
  建立名为hibernate.cfg.xml的文件。实例化Configuration config = new Configuration().Configure();这样NHibernate将会在目录下寻找hibernate.cfg.xml的配置文件。
  hibernate.cfg.xml的格式

<?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.0" > <session-factory name="MySessionFactory"> <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="connection.connection_string">Server=TLSZ207\SQLEXPRESS;initial catalog=Test;Integrated Security=true</property> </session-factory> </hibernate-configuration>

  指明配置文件
  Configuration config = new Configuration().Configure(configFileName);
  这种配置方法将查找指定的Hibernate标准配置文件,可以是绝对路径或者相对路径。还可以通过编码的方式来添加配置信息:
  IDictionary props = new Hashtable();
  props[“dialect”] = "NHibernate.Dialect.MsSql2005Dialect";
...
  Configuration cfg = new Configuration();
  cfg.Properties = props;//cfg.AddProperties(props);

  映射文件:
  所有的XML映射都需要使用nhibernate-mapping-2.0 schema。目前的schema可以在NHibernate的资源路径或者是NHibernate.dll的嵌入资源(Embedded Resource)中找到。NHibernate总是会优先使用嵌入在资源中的schema文件。你可以将hibernate-mapping拷贝到 C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\xml路径中,以获得智能感知功能。

<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Test" assembly="Test"> <class name="Test.Cat,Test" table="Cat"> <id name="CatID"> <column name="CatID" sql-type="char(32)" not-null="true"/> <generator class="uuid.hex" /> </id> <property name="Name"> <column name="Name" length="16" not-null="true" /> </property> <property name="Sex" /> <property name="Weight" /> </class> </hibernate-mapping>