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"