I am working on AdventureWorks database 2005.
So I need mapping table Customer with table has schema Sales.Customer
But an Exception occur (please scroll down to view full stack trace of exception).
And here is SQL string generated
Select customer0_.CustomerID as CustomerID0_, customer0_.TerritoryID as Territor2_0_, customer0_.AccountNumber as AccountN3_0_, customer0_.CustomerType as Customer4_0_, customer0_.ModifiedDate as Modified5_0_, customer0_.rowguid as rowguid0_ from Sales.Customer customer0_
then run Ok with SQL2005.
While with Adventure database same mapping file and code run on SQL 2000 and Customer table has default schema dbo then run ok.
Please help me.
Hibernate version:
1.2 GA
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="SmartManagement.Entities" namespace="SmartManagement.Entities" >
<class name="Customer" table="Customer" schema="Sales">
<id name="CustomerID" type="System.Int32" column="CustomerID">
<generator class="identity"/>
</id>
<property name="TerritoryID" column="TerritoryID" type="System.Byte" not-null="false" />
<property name="AccountNumber" column="AccountNumber" type="System.Int32" not-null="true" />
<property name="CustomerType" column="CustomerType" type="System.String" not-null="true" length="1"/>
<property name="ModifiedDate" column="ModifiedDate" type="System.DateTime" not-null="true" />
<property name="Rowguid" column="rowguid" type="System.Guid" not-null="true" />
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
A first chance exception of type 'NHibernate.ADOException' occurred in NHibernate.dll
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>SmartManagement.vshost.exe</AppDomain><Exception><ExceptionType>NHibernate.ADOException, NHibernate, Version=1.2.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4</ExceptionType><Message>could not execute query
[ select customer0_.CustomerID as CustomerID0_, customer0_.TerritoryID as Territor2_0_, customer0_.AccountNumber as AccountN3_0_, customer0_.CustomerType as Customer4_0_, customer0_.ModifiedDate as Modified5_0_, customer0_.rowguid as rowguid0_ from Sales.Customer customer0_ ]
[SQL: select customer0_.CustomerID as CustomerID0_, customer0_.TerritoryID as Territor2_0_, customer0_.AccountNumber as AccountN3_0_, customer0_.CustomerType as Customer4_0_, customer0_.ModifiedDate as Modified5_0_, customer0_.rowguid as rowguid0_ from Sales.Customer customer0_]</Message><StackTrace> at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
at NHibernate.Hql.Classic.QueryTranslator.List(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters, IList results)
at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters)
at NHibernate.Impl.QueryImpl.List()
at SmartManagement.DAL.FactoryDao.AbstractNHibernateDao`2.GetByHQL(String pHQL) in D:\ToanVo\SmartManagement\SmartManagement\SmartManagement.DAL\FactoryDao\AbstractNHibernateDao.cs:line 76
at SmartManagement.BLL.CustomerBLL.GetAll() in D:\ToanVo\SmartManagement\SmartManagement\SmartManagement.BLL\CustomerBLL.cs:line 21
at SmartManagement.Form1.button1_Click(Object sender, EventArgs e) in D:\ToanVo\SmartManagement\SmartManagement\SmartManagement\Form1.cs:line 24
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
at System.Windows.Forms.Button.WndProc(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at SmartManagement.Program.Main() in D:\ToanVo\SmartManagement\SmartManagement\SmartManagement\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>NHibernate.ADOException: could not execute query
[ select customer0_.CustomerID as CustomerID0_, customer0_.TerritoryID as Territor2_0_, customer0_.AccountNumber as AccountN3_0_, customer0_.CustomerType as Customer4_0_, customer0_.ModifiedDate as Modified5_0_, customer0_.rowguid as rowguid0_ from Sales.Customer customer0_ ]
[SQL: select customer0_.CustomerID as CustomerID0_, customer0_.TerritoryID as Territor2_0_, customer0_.AccountNumber as AccountN3_0_, customer0_.CustomerType as Customer4_0_, customer0_.ModifiedDate as Modified5_0_, customer0_.rowguid as rowguid0_ from Sales.Customer customer0_] ---&gt; System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Convert.ToInt32(Object value)
at NHibernate.Type.Int32Type.Get(IDataReader rs, Int32 index)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Type.AbstractType.Hydrate(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Loader.Loader.Hydrate(IDataReader rs, Object id, Object obj, ILoadable persister, ISessionImplementor session, String[][] suffixedPropertyColumns)
at NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i, Object obj, Type instanceClass, EntityKey key, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session)
at NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, EntityKey key, LockMode lockMode, EntityKey optionalObjectKey, Object optionalObject, IList hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters, EntityKey[] keys, Object optionalObject, EntityKey optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
Name and version of the database you are using:
AdventureWorks version for SQL 2005
and
AdventureWorks version for SQL 2000
The generated SQL (show_sql=true):
select customer0_.CustomerID as CustomerID0_, customer0_.TerritoryID as Territor2_0_, customer0_.AccountNumber as AccountN3_0_, customer0_.CustomerType as Customer4_0_, customer0_.ModifiedDate as Modified5_0_, customer0_.rowguid as rowguid0_ from Sales.Customer customer0_
|