NHibernate提示表is not mapped
一定要將hbm.xml對映檔案設定成嵌入的資源。
下面是mysql的對映檔案:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name=" wh.db.test.model.Test, wh.db.test.model" table="test">
<!--主鍵-->
<id name="id" column="id" type="string" unsaved-value="0">
<!--非自增主鍵應該配置為assigned屬性,自增主鍵應該配置成native-->
<generator class="assigned" />
</id>
<property name="name" column="name" type="string"/>
<property name="sex" column="sex" type="int"/>
<property name="address" column="address" type="string"/>
<property name="work" column="work" type="string"/>
</class>
</hibernate-mapping>
下面是oracle的對映檔案:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="EPAP.SZ.Models.B_R_Szmjobcar, EPAP.SZ.Models" table="B_R_SZMJOBCAR">
<id name="Jobcarid" column="JOBCARID" type="int">
<generator class="sequence">
<param name="sequence">B_R_SZMJOBCAR_SEQ</param>
</generator>
</id>
<!--系統標識-->
<property name="Epapid" column="EPAPID" type="string" />
<!--作業分工單ID-->
<property name="Jdlistid" column="JDLISTID" type="int" />
<!--汽車管理ID-->
<property name="Carinfoid" column="CARINFOID" type="int" />
<!--車號-->
<property name="Carno" column="CARNO" type="string" />
<!--汽車司機-->
<property name="Driver" column="DRIVER" type="string" />
<!--汽車司機ID-->
<property name="Driverid" column="DRIVERID" type="string" />
<!--汽車司機電話-->
<property name="Drivertel" column="DRIVERTEL" type="string" />
<!--乘客-->
<property name="Passengers" column="PASSENGERS" type="string" />
<!--乘客ID-->
<property name="Passengersid" column="PASSENGERSID" type="string" />
<!--編號-->
<property name="Serialnumber" column="SERIALNUMBER" type="int" />
<!--作業前送地點-->
<property name="Sendaddress" column="SENDADDRESS" type="string" />
<!--作業後接地點-->
<property name="Receiveaddress" column="RECEIVEADDRESS" type="string" />
<!--出車時間-->
<property name="Dispatchtime" column="DISPATCHTIME" type="DateTime" />
<!--司機攜帶工具id-->
<property name="DriverCarryToolId" column="DRIVERCARRYTOOLID" type="int" />
</class>
</hibernate-mapping>
mysql的web.config配置參考:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
<!--用Log4Net記錄NHibernate中執行的SQL語句及執行時間-->
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<!--NHibernate配置-->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
<!-- 版本改為 5-->
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<!--使用什麼資料庫-->
<property name="connection.connection_string">Server=127.0.0.1;Database=whtest;User ID=root;Password=123456</property>
<!-- Data Source=FirstSample.sdf 改為Server= localhost;Database=mygamedb;user ID=root;Password=root -->
<property name="show_sql">true</property>
<!--不配置hbm2ddl會報列“ReservedWord”不屬於表 ReservedWords的錯誤-->
<property name="hbm2ddl.keywords">none</property>
<!--載入對映-->
<mapping assembly="wh.db.test.model"/>
</session-factory>
</hibernate-configuration>
<!--log4net配置-->
<log4net debug="true">
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
<param name="File" value="D:\\Services\\Logs\\Error\\" />
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyyMM\\yyyy-MM-dd".log"" />
<param name="StaticLogFileName" value="false" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<!--只接受最小等級與最大等級之間的日誌輸出,其他的被過濾,這裡接受WARN(警告),ERROR(錯誤),FATAL(致命)級別的輸出-->
<param name="LevelMin" value="WARN" />
<param name="LevelMax" value="FATAL" />
</filter>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="ErrorLog" />
</root>
</log4net>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<!--需要配置該節點,不然HttpContext.current是為空的-->
<httpModules>
<add name="NHSessionFactory" type="wh.db.test.dao.DataBase.NHSessionFactory" />
</httpModules>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 為避免洩漏後設資料資訊,請在部署前將以下值設定為 false 並刪除上面的後設資料終結點 -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 要接收故障異常詳細資訊以進行除錯,請將以下值設定為 true。在部署前設定為 false 以避免洩漏異常資訊 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--必須配置aspNetCompatibilityEnabled為true否則HttpContext.current為空-->
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
oracle的web.config參考:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
<!--用Log4Net記錄NHibernate中執行的SQL語句及執行時間-->
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<appSettings file="Config/EPAPConfig.config">
<add key="Epapid" value="025" />
<add key ="WebUrl" value="http://192.168.1.161:1125"/>
</appSettings>
<!--nhibernate配置-->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="ora10gFactory">
<property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider, NHibernate</property>
<property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
<!--<property name="connection.driver_class">NHibernate.Driver.OracleManagedDataClientDriver</property>-->
<property name="connection.connection_string">
<!--User Id=epapsz;Password=epapsz;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=TMIS)))-->
</property>
<property name="adonet.batch_size">10</property>
<property name="show_sql">false</property>
<property name="command_timeout">60</property>
<!--載入hibernate自動更新資料庫結構,update為更新,none為不更新-->
<property name="hbm2ddl.auto">none</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<property name="proxyfactory.factory_class">NHibernate.Bytecode.DefaultProxyFactoryFactory,NHibernate</property>
<property name="hbm2ddl.keywords">none</property>
<property name="cache.provider_class">NHibernate.Cache.HashtableCacheProvider</property>
<property name="cache.use_second_level_cache">false</property>
<property name="cache.use_query_cache">false</property>
<!--載入對映-->
<mapping assembly="EPAP.SZ.Models" />
<mapping assembly="EPAP.SZ.ViewModels" />
</session-factory>
</hibernate-configuration>
<!--log4net配置-->
<log4net debug="true">
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
<param name="File" value="D:\\Services\\Logs\\Error\\" />
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyyMM\\yyyy-MM-dd".log"" />
<param name="StaticLogFileName" value="false" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<!--只接受最小等級與最大等級之間的日誌輸出,其他的被過濾,這裡接受WARN(警告),ERROR(錯誤),FATAL(致命)級別的輸出-->
<param name="LevelMin" value="WARN" />
<param name="LevelMax" value="FATAL" />
</filter>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="ErrorLog" />
</root>
</log4net>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpModules>
<add name="NHSessionFactory" type="EPAP.SZ.DAL.DataBase.NHSessionFactory" />
</httpModules>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 為避免洩漏後設資料資訊,請在部署前將以下值設定為 false 並刪除上面的後設資料終結點 -->
<serviceMetadata httpGetEnabled="true" />
<!-- 要接收故障異常詳細資訊以進行除錯,請將以下值設定為 true。在部署前設定為 false 以避免洩漏異常資訊 -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<!--管理會話狀態-->
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
<!--考勤一體機服務-->
<bindings>
<basicHttpBinding>
<!--其實要修改所有的服務,不管是服務端還是客戶端,Binding那邊增加一個沒有設定名字的預設配置就OK了 maxBufferSize="2147483647"-->
<binding closeTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
</binding >
</basicHttpBinding>
</bindings>
<!--考勤一體機服務end-->
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
</configuration>
相關文章
- USING NHIBERNATE WITH MySQLMySql
- NHibernate 快速入門
- Using NHibernate with SQLiteSQLite
- Nhibernate教程2(4)
- NHibernate查詢示例合集
- NHibernate 慎用Session.MergeSession
- HTTP錯誤提示資訊表HTTP
- 在nhibernate中執行SQL語句SQL
- 搞懂 TypeScript 中的對映型別(Mapped Types)TypeScript型別APP
- 13.there is no action mapped for namespace and action name associated with contAPPnamespace
- 如何在C#專案中使用NHibernateC#
- Nhibernate 對view 查詢的幾種方法View
- NHibernate Criteria中 Restriction與Expression的差別RESTExpress
- 字母表;及查詢提示分析
- Bootstrap系列 -- 21. 表單提示資訊boot
- struts2的異常There is no Action mapped for namespace / and action nameAPPnamespace
- C# 資料操作系列 - 10 NHibernate初試C#
- NHibernate 多對多對映的資料更新
- 泛微oa流程表單之比值提示
- 表單提示美化效果程式碼例項
- java.lang.IllegalArgumentException: Mapped Statements collection does not contain value forJavaExceptionAPPAI
- Why NHibernate updates DB on commit of read-only transactionMIT
- ORA-07445 [kkoipt()+3881] [SIGSEGV] [Address not mapped to object]GseAPPObject
- Some characters cannot be mapped using 'ISO-8859-1' character encodingAPPEncoding
- Vue-手動清空Form表單的驗證及驗證提示(紅字提示)VueORM
- 讓OData和NHibernate結合進行動態查詢
- 用LinqPad檢視Nhibernate生成的sql語句SQL
- One to One 的資料庫模型設計與NHibernate配置資料庫模型
- 『Spring.NET+NHibernate+泛型』框架搭建之Model(二)Spring泛型框架
- NHibernate “login: method get_Upwd should be virtual”錯誤解答!
- NHibernate中文翻譯文件(整理自DDLLY名稱空間)
- ElementUI 中 table 表格自定義表頭 Tooltip 文字提示UI
- 將laravel框架表單錯誤提示中文化Laravel框架
- ORA-07445:oracle_[type: SIGSEGV, Address not mapped to object]OracleGseAPPObject
- ORA-07445 [opidsa()+386] [SIGSEGV] [Address not mapped to object]GseAPPObject
- C# 資料操作系列 - 12 NHibernate的增刪改查C#
- NHibernate VS .NET Type VS DbType 的型別對映關係型別
- ORA-07445: [opitca()+4618] [SIGSEGV] [Address not mapped to object]GseAPPObject