NHibernate could not get or update next value[SQL: ] 物件名 'hibernate_unique_key' 無效。
錯誤資訊:
---------------------------
---------------------------
NHibernate.Exceptions.GenericADOException: could not get or update next value[SQL: ] ---> System.Data.SqlClient.SqlException: 物件名 'hibernate_unique_key' 無效。
在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
在 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
在 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
在 System.Data.SqlClient.SqlDataReader.get_MetaData()
在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
在 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
在 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
在 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
在 NHibernate.Id.TableGenerator.DoWorkInCurrentTransaction(ISessionImplementor session, IDbConnection conn, IDbTransaction transaction)
在 NHibernate.Engine.TransactionHelper.Work.DoWork(IDbConnection connection, IDbTransaction transaction)
--- 內部異常堆疊跟蹤的結尾 ---
在 NHibernate.Engine.TransactionHelper.Work.DoWork(IDbConnection connection, IDbTransaction transaction)
在 NHibernate.Transaction.AdoNetTransactionFactory.ExecuteWorkInIsolation(ISessionImplementor session, IIsolatedWork work, Boolean transacted)
在 NHibernate.Transaction.AdoNetWithDistributedTransactionFactory.ExecuteWorkInIsolation(ISessionImplementor session, IIsolatedWork work, Boolean transacted)
在 NHibernate.Engine.Transaction.Isolater.DoIsolatedWork(IIsolatedWork work, ISessionImplementor session)
在 NHibernate.Engine.TransactionHelper.DoWorkInNewTransaction(ISessionImplementor session)
在 NHibernate.Id.TableGenerator.Generate(ISessionImplementor session, Object obj)
在 NHibernate.Id.TableHiLoGenerator.Generate(ISessionImplementor session, Object obj)
在 NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)
在 NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
在 NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
在 NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event)
在 NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event)
在 NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event)
在 NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event)
在 NHibernate.Impl.SessionImpl.Save(Object obj)
在 WindowsFormsApplication1.Form1.Form1_Load(Object sender, EventArgs e) 位置 C:\Users\JianKunKing\Desktop\NHibernate\NHibernate03\WindowsFormsApplication1\Form1.cs:行號 41
---------------------------
確定
---------------------------
解決方法:
I’ve genereated a schema for my (SQL 2005) db using SchemaExport, and it’s created a table
CREATE TABLE [dbo].[hibernate_unique_key](
[next_hi][int] NULL
) ON [PRIMARY]
When I try to add an entity, I get the error:
---------------------------
---------------------------
NHibernate.Id.IdentifierGenerationException: could not read a hi value - you need to populate the table: hibernate_unique_key
在 NHibernate.Id.TableGenerator.DoWorkInCurrentTransaction(ISessionImplementor session, IDbConnection conn, IDbTransaction transaction)
在 NHibernate.Engine.TransactionHelper.Work.DoWork(IDbConnection connection, IDbTransaction transaction)
在 NHibernate.Transaction.AdoNetTransactionFactory.ExecuteWorkInIsolation(ISessionImplementor session, IIsolatedWork work, Boolean transacted)
在 NHibernate.Transaction.AdoNetWithDistributedTransactionFactory.ExecuteWorkInIsolation(ISessionImplementor session, IIsolatedWork work, Boolean transacted)
在 NHibernate.Engine.Transaction.Isolater.DoIsolatedWork(IIsolatedWork work, ISessionImplementor session)
在 NHibernate.Engine.TransactionHelper.DoWorkInNewTransaction(ISessionImplementor session)
在 NHibernate.Id.TableGenerator.Generate(ISessionImplementor session, Object obj)
在 NHibernate.Id.TableHiLoGenerator.Generate(ISessionImplementor session, Object obj)
在 NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)
在 NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
在 NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
在 NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event)
在 NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event)
在 NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event)
在 NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event)
在 NHibernate.Impl.SessionImpl.Save(Object obj)
在 WindowsFormsApplication1.Form1.Form1_Load(Object sender, EventArgs e) 位置 C:\Users\JianKunKing\Desktop\NHibernate\NHibernate03\WindowsFormsApplication1\Form1.cs:行號 42
---------------------------
確定
---------------------------
Solution:
NHibernate expects to find a value that stores the current hi value in that table, ie it first runs something like:
current_hi =[SELECT max(next_hi) FROM hibernate_unique_key].
So all you need to do is seed that table with an initial number, ie:
INSERT INTO hibernate_unique_key(next_hi) VALUES (0)
參考文章:
在部署OLAT到myeclipse,資料庫配置正確的情況下,出現異常:Error with hilo in NHibernate - “could not read a hi value - you
相關文章
- 教你如何解決SQL server中提示物件名無效SQLServer物件
- apt could not get lockAPT
- Linux學習之出現無法apt-get updateLinuxapt-get
- java.sql.SQLSyntaxErrorExceptionORA-00911無效字元JavaSQLErrorException字元
- SQL__UPDATESQL
- jedis異常:Could not get a resource from the pool
- sudo apt-get update | grep "Failed"apt-getAI
- 【SQL】10 SQL UPDATE 語句SQL
- How to update BOL entity property value via ABAP code
- Sql server with as update用法SQLServer
- WebLogic啟動報Could not get the server file lockWebServer
- win10 excel .xlsx檔案格式無效或副檔名無效怎麼辦Win10Excel
- get_attribute ('textContent') 和 get_attribute ('value') 有什麼區別
- MyBatis - java.sql.SQLSyntaxErrorException: ORA-00911: 無效字元MyBatisJavaSQLErrorException字元
- springboot報錯無法讀取配置檔案中的屬性:Could not resolve placeholder ‘xxxx‘ in value “${xxxx}Spring Boot
- centOS修改主機名,重啟後無效解決CentOS
- sql查詢更新update selectSQL
- redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the poolRedisclientException
- MyBatis - java.sql.SQLException: 無效的列型別: 1111MyBatisJavaSQLException型別
- MySQL服務名無效或者MySQL正在啟動 MySQL無法啟動MySql
- NHibernate提示表is not mappedAPP
- 解決bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: 無效字元SQLExceptionJavaError字元
- [20180808]Null value to Dynamic SQL.txtNullSQL
- java.sql.SQLException: Incorrect string valueJavaSQLException
- Android error “Could not get BatchedBridge, make sure your bundle is packaged properly” on start ofAndroidErrorBATPackage
- Kettle: pentaho-server-ce-9.4 : ERROR [SchemaUpdate] could not get database metadataServerErrorDatabase
- ubuntu解決Could not get lock /var/lib/dpkg/lock-frontendUbuntu
- Linux報錯:Could not get lock /var/lib/dpkg/lock-frontendLinux
- Oracle SQL_ID轉換成SQL_HASH_VALUEOracleSQL
- ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00909: 引數個數無效SQLExceptionJavaError
- win10合併分割槽到c盤顯示包名稱無效怎麼辦?win10顯示包名稱無效解決方法Win10
- win10提示檔案格式或副檔名無效怎麼辦_win10 excel檔案格式或副檔名無效的解決方法Win10Excel
- 無效字元字元
- Ubuntu學習之apt-get update 升級錯誤Ubuntuapt-get
- apt-get update 和 apt-get install 寫在同一個 RUN 指令的解讀apt-get
- Oracle利用errorstack追蹤tomcat報錯ORA-00903 無效表名OracleErrorTomcat
- 如何拿到註解@ApiModelProperty(value = “單位名稱“, name = “orgName“)中的value值;API
- 遞迴遍歷物件獲取value值遞迴物件
- [Error Code: 904, SQL State: 42000] ORA-00904 : 識別符號無效ErrorSQL符號