我一直在努力将应用程序转换为使用NoDateTime库,并且遇到了即时属性映射的问题。
根据文档:http://www.npgsql.org/doc/types/nodatime.html 我应该能够将Instant映射到Postgresql时间戳 我正在使用conn.TypeMapper.UseNodaTime(); 我得到的错误是: 42804 列 instantdate 的类型为timestamp,没有时区,但表达式的类型为bytea
使用nhibernates属性映射属性,对此属性未设置任何属性(将属性设置为timestamp时会出现不同的错误)。
任何人都可以指出我需要做些什么才能使它工作?
使用:
生成的插入语句:
NHibernate.IDbCommand: INSERT INTO TestDates (InstantDate, LocalDate, ZonedDate, Id) VALUES (:p0, :p1, :p2, :p3);:p0 = 0x0001000000FFFFFFFF01000000000000000C020000004B4E6F646154696D652C2056657273696F6E3D322E332E302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D343232366166653064396232393664310501000000104E6F646154696D652E496E7374616E740200000004646179... [Type: Binary (0:0:0)], :p1 = 0x0001000000FFFFFFFF01000000000000000C020000004B4E6F646154696D652C2056657273696F6E3D322E332E302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D343232366166653064396232393664310501000000164E6F646154696D652E4C6F63616C4461746554696D650500... [Type: Binary (0:0:0)], :p2 = 0x0001000000FFFFFFFF01000000000000000C020000004B4E6F646154696D652C2056657273696F6E3D322E332E302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D343232366166653064396232393664310501000000164E6F646154696D652E5A6F6E65644461746554696D650700... [Type: Binary (0:0:0)], :p3 = 3020013646600 [Type: Int64 (0:0:0)]
完整堆栈跟踪:
Error NHibernateLogger NHibernate: Could not synchronize database state with session NHibernate.Exceptions.GenericADOException: could not insert: [ISC.iNet.DataAccess.TestDates#3020013676600][SQL: INSERT INTO TestDates (InstantDate, LocalDate, ZonedDate, Id) VALUES (?, ?, ?, ?)] ---> Npgsql.PostgresException: 42804: column "instantdate" is of type timestamp without time zone but expression is of type bytea
at Npgsql.NpgsqlConnector.<>c__DisplayClass161_0.<<ReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Npgsql.NpgsqlConnector.<>c__DisplayClass161_0.<<ReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlDataReader.<NextResult>d__46.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlDataReader.NextResult()
at Npgsql.NpgsqlCommand.<ExecuteDbDataReader>d__100.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlCommand.<ExecuteNonQuery>d__92.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlCommand.ExecuteNonQuery()
at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation expectation)
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session)
--- End of inner exception stack trace ---
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session)
at NHibernate.Action.EntityInsertAction.Execute()
at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)