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>
相關文章
- 基於jqgrid + ashx + nhibernate的分頁
- 如何在C#專案中使用NHibernateC#
- 13.there is no action mapped for namespace and action name associated with contAPPnamespace
- C# 資料操作系列 - 10 NHibernate初試C#
- 搞懂 TypeScript 中的對映型別(Mapped Types)TypeScript型別APP
- 表頭問號提示語
- C# 資料操作系列 - 12 NHibernate的增刪改查C#
- 解決mybatis出現Mapped Statements collection already contains value for問題MyBatisAPPAI
- ORA-07445: exception encountered: core dump [kksIsNLSEqual()+72] [SIGSEGV] [Address not mapped to obExceptionGseAPP
- C# 資料操作系列 - 11 NHibernate 配置和結構介紹C#
- 泛微oa流程表單之比值提示
- 發表文章時提示有垃圾內容?
- Vue-手動清空Form表單的驗證及驗證提示(紅字提示)VueORM
- django執行migrate無法生成表,提示 No migrations to applyDjangoAPP
- ElementUI 中 table 表格自定義表頭 Tooltip 文字提示UI
- 將laravel框架表單錯誤提示中文化Laravel框架
- Maven建立SSM專案 啟動時報錯Mapped Statements collection does not contain value for xxxMavenSSMAPPAI
- 輸入框前面帶有表單驗證提示的功能
- PG 修改表結構提示有試圖依賴的處理方法
- element-ui裡Form 表單內給label內容新增圖示提示UIORM
- Flutter Toast、彈出提示、輕提示FlutterAST
- 【資料庫】解決Mysql資料庫提示innodb表不存在的問題!資料庫MySql
- 織夢DEDECMS自定義表單提示資料校驗不對,程式自動返回
- 更好用、能擴充套件、支援多國語言提示的表單驗證類庫套件
- 提示詞工程
- myeclipse中提示Hot Code Replace Failed提示窗錯誤EclipseAI
- 易優CMS安裝時,提示在寫入表ey_weapp_multicity記錄失敗-eyoucmsAPP
- 帝國CMS安裝時出現如下提示 “建立資料表: phome_ecms_article 完畢......
- Minstrel自動生成結構化提示,讓AI為AI寫提示詞的多代理提示生成框架AI框架
- tooltip提示框
- CSS 專家提示CSS
- elementUI loading提示使用UI
- 如何使用提示詞
- Prompt提示詞概念
- vue提示訊息Vue
- 根據提示操作
- springboot配置sql提示Spring BootSQL
- win10系統玩dnf提示圖表系統組建失敗視窗如何解決Win10