NHibernate development environment and configuration-nhibernate Getting started to Master Series 2

Source: Internet
Author: User
Tags mssql reflection

Previous: NHibernate ORM Introduction and advantages and disadvantages-nhibernate Introduction to proficient in Series 1 introduced NHibernate and ORM, the reader has a perceptual understanding.

In this section, you will continue with this system, introducing: NHibernate development environment and configuration and its architectural knowledge.

The following is the body content:

One, the development environment of NHibernate

Website address: http://nhforge.org/

NHibernate3 is currently the latest version, its download address is: http://sourceforge.net/projects/nhibernate/files/NHibernate/

After downloading and decompressing the Nhibernate-3.0.0.ga-bin.zip, as shown in Figure 1.1.

Folder Description:

Required_bins:nhiberante The main program's DLL assembly.

(1). Antlr3.Runtime.dll is: An assembly of ANTLR. ANTLR (ANother Tool for Language recognition) is a tool that provides a basis for constructing our own recognizers (recognizers), compilers (compiler), and converters (translators). By defining your own language rules, ANTLR can generate the corresponding language parser for us, so that we can save ourselves all the manual labor.

(2). Iesi.Collections.dll is the collection Library of the NHibernate program, because in the. NET4.0 did not provide such a collection as Iset, so the designers of the Nhiberante framework placed iset such collections in the assembly. I suggest that the designer of the Nhiberante framework, in the NET4.0 program, use the System.collections.generic.iset<t> interface.

(3). NHibernate.dll Main assembly

(4). Remotion.Data.Linq.dll is: NHibernate to Linq class library.

(5). Nhibernate-configuration.xsd and NHibernate- Mapping.xsd the XSD files for the NHibernate program configuration and mapping configuration, we copy the two files to the \xml\schemas of the Microsoft Visual Studio installation directory, and there will be an automatic Xml prompt. The folder named "Required_for_lazyloading" places the assemblies used by the Nhiberante delay loading agent, which provides the three proxy classes for Castle, Linfu, and spring. I can choose one of them. The folder named "Configuration_templates" is placed in a Nhiberante configuration template. Configuration templates for Firebird, MSSQL, MYSQL, Oracle, PostgreSQL, SQLite have been given.

Second: NHibernate development environment and configuration

Because NHibernate is designed to work in a variety of different environments, there are a number of configuration parameters. Fortunately, most configuration parameters have a more intuitive default value. I open the Mssql.cfg file and, as shown, I can observe the configuration of the nhibernate.

Figure 3.1

3.1 NHibernate provides ado.net connection configuration

Property name

Use

Connection.provider_class

Implements the type of the Iconnectionprovider interface.

For example: (If the Iconnectionprovider implementation class within the NHibernate) Full.classname.of.ConnectionProvider,

(If it is a custom nhibernate external Iconnectionprovider implementation Class) Full.classname.of.ConnectionProvider, assembly.

Connection.driver_class

If you use Driverconnectionprovider, implement the type of Idriver interface.

(If it is the idriver type of the implementation within the NHibernate) full.classname.of.Driver

(If it is a custom nhibernate external Idriver implementation Class) Full.classname.of.Driver, assembly.

This configuration is usually not required to configure, if set up Hibernate.dialect generally will automatically select the corresponding idriver.
Detailed dialect the default correspondence with Idriver to view the API documentation.

Connection.connection_string

Database connection string

Connection.connection_string_name

The database connection string name, defined in the. NET configuration file <connectionStrings> configuration section, the name of the connection string.

Connection.isolation

Ado. NET transaction isolation level, view the System.Data.IsolationLevel class to understand the specific meaning of each value, but note that most databases do not support all isolation levels.

For example: Chaos, readcommitted, ReadUncommitted, RepeatableRead, Serializable, Unspecified

Connection.release_mode

Specifies when Ado.net releases the database connection.

Example: Auto (default) | On_close | After_transaction

Note that these settings only work with ISession that are obtained through isessionfactory.opensession.

For the ISession obtained through Isessionfactory.getcurrentsession,

The configured Icurrentsessioncontext implementation controls the connection release mode of these isession.

Command_timeout

Specifies the timeout for nhibernate-generated idbcommands objects.

Adonet.batch_size

Specifies the number of batch updates with Ado.net, with the default setting of 0 (this feature is not enabled).

Proxyfactory.factory_class

Agent Factory configuration. Used to specify which middleware provides a deferred load agent


3.2 Optional Configuration Properties

There are a number of properties that can be used to control the behavior of NHibernate during the run time. They are all optional and have the appropriate default values.

Property name

Use

Dialect

Set NHibernate dialect class name-allows nhibernate to generate optimized SQL for specific relational databases

Available values: Full.classname.of.Dialect, assembly

Default_schema

In the generated SQL, attach the given schema/tablespace to the table name of a non fully qualified name.

Available values: schema_name

Use_outer_join

Allow external connection crawl, deprecated, use max_fetch_depth.

Available values: TRUE | False

Max_fetch_depth

Sets the maximum depth for the outer join fetch tree for one-way association (one-to-one, Many-to-many).

A value of 0 means that the default outer join crawl will be turned off

Available values: It is recommended to take a value between 0 and 3.

Use_reflection_optimizer

Turn on Run-time code generation to override Run-time reflection mechanisms (System-level attributes).

In this way, the program can be started with a certain amount of performance, but the performance of the program during the run period will be improved.

Note that even if this optimization is turned off, hibernate still needs cglib. You cannot set this property in Hibernate.cfg.xml.

This property cannot be set in Hibernate.cfg.xml or in the application configuration file

Available values: TRUE | False

Bytecode.provider

Specifies bytecode provider to optimize nhibernate reflection performance. Null represents a complete shutdown of performance optimizations,

LCG is used for lightweight code dynamic generation, and CodeDom is generated dynamically based on CodeDom code.

Available values: null

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.