Nhib.pdf Summary

Source: Internet
Author: User

Nhib.pdf requires the model object class for lazy = "true". Before the field attribute, add virtual

How to configure hibernate. cfg. xml of sqlserver2005 and oracle10g?
A: sqlserver2005 configuration is as follows:
<! -- Nhib1_sqlserver2005 configuration -->
<Hibernate-configuration xmlns = "urn: nhibernate-configuration-2.2">
<Session-factory name = "db1">
<! -- Properties -->
<Property name = "connection. provider"> nhib.pdf. Connection. DriverConnectionProvider </property>
<Property name = "connection. driver_class"> nhib.pdf. Driver. SqlClientDriver </property>
<Property name = "dialect"> nhib.pdf. Dialect. MsSql2005Dialect </property>
<Property name = "connection. connection_string">
Server =.; initial catalog = NhibernateTest; User Id = sa; Password = sa
</Property>
<Property name = "use_outer_join"> true </property>
<Property name = "use_proxy_validator"> true </property>
<! -- <Property name = "show_ SQL"> false </property> -->
<! -- <Property name = "query. substitutions"> true 1, false 0, yes 'y', no 'n' </property> -->
<! -- Mapping files -->
<Mapping assembly = "Kang. Model"/>
</Session-factory>
</Hibernate-configuration>

The Oracle10g configuration is as follows:
<! -- Nhib1_oracle10g configuration -->
<Hibernate-configuration xmlns = "urn: nhibernate-configuration-2.2">
<Session-factory name = "db1">
<! -- Properties -->
<Property name = "connection. provider"> nhib.pdf. Connection. DriverConnectionProvider </property>
<Property name = "connection. driver_class"> nhib.pdf. Driver. OracleClientDriver & lt </property>
<Property name = "dialect"> nhib.pdf. Dialect. Oracle9Dialect & lt </property>
<Property name = "connection. connection_string">
Data source = KANGSHI; User ID = huobj; Password = huobj
</Property>
<Property name = "use_outer_join"> true </property>
<Property name = "use_proxy_validator"> true </property>
<! -- <Property name = "show_ SQL"> false </property> -->
<! -- <Property name = "query. substitutions"> true 1, false 0, yes 'y', no 'n' </property> -->
<! -- Mapping files -->
<Mapping assembly = "Kang. Model"/>
</Session-factory>
</Hibernate-configuration>

Q: You cannot forcibly convert an object of the type "nhib.pdf. Dialect. MsSqlCeDialect" to the type "nhib.pdf. Driver. IDriver ".
A: When switching the database, the corresponding connection. driver_class attribute needs to be adjusted.
Oracle10g is nhib.pdf. Driver. OracleClientDriver
MsSql2005 is nhib.pdf. Driver. SqlClientDriver

Q: cocould not execute query
A: The general principle is that the Nhibernate query still complies with the original SQL rules.
1. The field name is incorrect,
2. The field format is incorrect. Pay attention to the date, number, and character.
3 & lt; property type = "string" length = "50" name = "RoleName" column = "[RoleName]"/& gt;
Oracle must remove [] of RoleName. Sqlsever does not need to go.
 

Q: The type System. Int32 can not be assigned to a property of type System. String setter of Kang. Model. Entities. USR_UserInfo.LoginID
A: The primary key LoginID is originally defined as int and should be changed to string.

Q: Invalid Cast (check your mapping for property type mismatches); setter of Kang. Model. Entities. USR_UserInfo
A: length = "80" must be smaller than the length of fields in the database table. In addition, the type of the attribute class in the object class must be the same as that in nhibernate-mapping.

Q: What are the differences between the Date, DateTime, and TimeStamp types in the database?
A:
DATETIME, DATE, and TIMESTAMP types are related. This article describes their features and how they are similar and different.
The DATETIME type is used when you need to include both the date and time information. MySQL retrieves and displays DATETIME values in 'yyyy-MM-DD HH: MM: ss' format, the supported range is '2017-01-01 00:00:00 'to '2017-12-31 23:59:59 '. ("Supported" means that although earlier values may work, they cannot be guaranteed .)
The DATE type is used when you only need the DATE value, and there is no time part. MySQL retrieves and displays the DATE value in 'yyyy-MM-DD 'format. The supported range is '2017-01-01' to '2017-12-31 '.
The TIMESTAMP column type provides a type that you can use to automatically mark INSERT or UPDATE operations with the current date and time. If you have multiple TIMESTAMP columns, only the first one is automatically updated.

SqlDateTime overflow. It must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
The Tick value must be between DateTime. MinValue. Ticks and DateTime. MaxValue. Ticks.
Parameter Name: ticks
A: In the object class, the private DateTime _ CreateDate = new DateTime (2009-9-9) is OK );

 

 
Q: Some guys write this, but the problem is troublesome.
Var whitelist = new [] {"UserId", "UserName", "UserParssord", "UserMail "};
UpdateModel (user, whitelist );
UService. UpdateUserInfo (user );
Return RedirectToAction ("Index ");
A: You can write it like this.
Model = bll. GetModel (id );
UpdateModel (model );
Bll. UpdateData (model );
Return RedirectToAction ("Index ")

Parent-Child table Association ing ============================================== ============
Q: The user code does not process nhib.pdf. PropertyAccessException.
Message = "Invalid Cast (check your mapping for property type mismatches); setter of Kang. Model. Entities. USR_UserInfo"
Source = "Kang. NHibernateHelper"
A: <! -- Multi-to-one relationship: Users belongs to a Role -->
<Role-to-one name = "RoleID" column = "RoleID" not-null = "true" class = "Kang. model. entities. roleInfo "foreign-key =" FK_RoleUsers "/>

<! -- One-to-many relationship: Role has one or more Users -->
<Set name = "Users" table = "'usr _ userinfo'" generic = "true" inverse = "true">
<Key column = "RoleInfo" foreign-key = "FK_RoleUsers"/>
<One-to-define class = "Kang. Model. Entities. USR_UserInfo"/>
</Set>
 
Q: Duplicate property mapping of RoleID found in Kang. Model. Entities. USR_UserInfo
A: duplicate attribute definitions exist. Property objectization: When the page call is displayed, the attribute can be called again, for example, model. RoleID. RoleName.

Q: cocould not initialize proxy-the owning Session is disconnected
A: For A parent-child table, set lazy = "false"

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.