Hold the whole body "nhibernate basic map"

Source: Internet
Author: User
Tags api manual connection pooling

with a full body to describe Nhibernate map, it's not exaggerated at all. The change of the small property determines the running dynamics of the whole Nhibernate. Let 's take a specific look at the configuration file we used in the previous article to add an understanding of the XML mapping file:

mapping files for entity classes:

An entity class corresponds to a table in the database; One of the properties in the class corresponds to a field in the table; The operation of an object corresponds to a record in the table.

<?xmlversion= "1.0" encoding= "Utf-8"? >


The <class></class> tag is defined as a persisted class.

Class name = "Dog" persisted class names, which can be the full name of the class.

table = database table name corresponding to "Dog ".

The <id><id> tag defines the mapping of this property to the primary key field of the database table.

  property name= "id" identifies the name of the attribute.

SQL -type="char (+)" nhibernate type name

column name = "Dogid" of the primary key field.

The <property></property> tag is a class that defines a property of a persisted class.

name ="PropertyName" Property name

column= The database field name for "column_name" .

type = name of the "TypeName" NHibernate.


Nhibernate The mode of operation of the configuration file, mainly configure the session factory:

<strong><</strong>?xmlversion= "1.0" encoding= "Utf-8"? >

 <property name="dialect">   ConfigurationDatabase dialect, there are different configurations for different data, and the current configuration isSqlseverthe dialect

<property name="connection.provider"> Configure connection Pooling

&NBSP;&NBSP; <property &NBSP; Span lang= "ZH-CN" style= "font-family: XXFarEastFont-Arial; Color:red ">name = " connection.connection_string " ; &NBSP;&NBSP; &NBSP;&NBSP;&NBSP; Property values everyone looks familiar. The string

that configures the connection database

< Property &NBSP; name = " Hbm2ddl.auto " >     The configuration of this property determines the nhibernate Whether the database table is automatically generated

&NBSP; <mapping &NBSP; Span lang= "ZH-CN" style= "font-family: XXFarEastFont-Arial; Color:red ">assembly = " Model " /> &NBSP; properties here config The assembly of the entity class to be loaded

The value of each property, there are many different configurations, you can consult the API manual, detailed to learn, here only to do simple sharing.

Summary: The configuration file brings great benefits to our program, from the abstract factory, to the NHibernate, which shows the flexibility it brings to the program. Configuration file, it will be a big line!

Hold the whole body "nhibernate basic map"

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.