Gunnar. Thanks for the reply. Sorry man but I didn't show you that the "*select ... *" code snip is in the create view code in SQL. Not in the application code.
I figured out what your perspective by re-writing my access, from the nice simple model construction, to now using a call to hbmSession.CreateQuery(). *Can you answer this question?* This doesn't work: var qry = ses.CreateQuery("select CustServSetRecid from vCustServSet order by CustServSetRecid") .SetResultTransformer(NHibernate.Transform.Transformers.AliasToBean(typeof(vCustServSet))) .List<vCustServSet>(); error stating *can't find getter for propert '0'* (property 0?) But this does: var qry = ses.CreateQuery("select CustServSetRecid *as CustServSetRecid* from vCustServSet order by CustServSetRecid") .SetResultTransformer(NHibernate.Transform.Transformers.AliasToBean(typeof(vCustServSet))) .List<vCustServSet>(); And yes this does not work, nHibernate doesn't parse out the semi-quotes in: var qry = ses.CreateQuery("select CustServSetRecid as *'CustServSetRecid'* from vCustServSet order by CustServSetRecid") .SetResultTransformer(NHibernate.Transform.Transformers.AliasToBean(typeof(vCustServSet))) .List<vCustServSet>(); But it doesn't make sense that all columns in a CreateQuery() will need an alias. Everyone here is scratching their heads. Such requirements just don;t seem to make sense. On Tuesday, March 22, 2016 at 11:20:56 AM UTC-4, Gunnar Liljas wrote: > > I meant in the SQL... > > select CAST(ROW_NUMBER() OVER(ORDER BY aa.ServiceRecid DESC) as int) AS > CustomerServiceSetRecid > > Note the cast, since ROW_NUMBER returns bigint > > Also, will this return the same CustomerServiceSetRecid all the time? > Updates, caching etc. will be dangerous if the "primary key" changes. > > /G > > 2016-03-22 13:45 GMT+01:00 Steve Lyle <ssl...@gmail.com <javascript:>>: > >> The suggestion entirely violates the XLM structure. >> Attribute values must be quoted. >> >> >> Also the query executed by nHibernate is successfully executed on SQL >> server. >> nHibernate successfully receives back the recordset results. >> >> The problem is that nHibernate doesn't like that the provided unique key >> is a calculated value (not a stored attribute of a table) that nHibernate >> can't manipulate ~~ even though I will never ask nHibernate to persist any >> of the recordset. >> >> >> >> >> On Monday, March 21, 2016 at 8:20:46 PM UTC-4, Steve Lyle wrote: >>> >>> My application calls and successfully receives a result set from my >>> database. >>> When I look in the log4net file I can even see the values of each field >>> of each row returned because the values are logged as DEBUG messages in the >>> log file. >>> >>> *But at the end of receiving the rows hbm fails complaining - from the >>> log at the failure:* >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Type.StringType - >>> returning 'VRM' as column: col_6_0_ >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Type.StringType - >>> returning 'Flash freeze' as column: col_7_0_ >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Type.Int32Type - returning >>> '14' as column: col_8_0_ >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Type.StringType - >>> returning 'steve2' as column: col_9_0_ >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Type.StringType - >>> returning 'steve2' as column: col_10_0_ >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Type.StringType - >>> returning 'steve2' as column: col_11_0_ >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Type.StringType - >>> returning 'steve2' as column: col_12_0_ >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Type.DateTimeType - >>> returning null as column: col_13_0_ >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Type.Int32Type - returning >>> null as column: col_14_0_ >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Type.StringType - >>> returning null as column: col_15_0_ >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Loader.Loader - done >>> processing result set (35 rows) >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.Driver.NHybridDataReader - >>> running NHybridDataReader.Dispose() >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.AdoNet.AbstractBatcher - >>> Closed IDataReader, open IDataReaders :0 >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.AdoNet.AbstractBatcher - >>> DataReader was closed after 32 ms >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.AdoNet.AbstractBatcher - >>> Closed IDbCommand, open IDbCommands: 0 >>> 2016-03-21 14:36:49,820 [11] DEBUG NHibernate.AdoNet.ConnectionManager - >>> aggressively releasing database connection >>> 2016-03-21 14:36:49,820 [11] DEBUG >>> NHibernate.Connection.ConnectionProvider - Closing connection >>> 2016-03-21 14:36:49,820 [11] DEBUG >>> NHibernate.Engine.StatefulPersistenceContext - initializing non-lazy >>> collections >>> 2016-03-21 14:36:49,840 [11] DEBUG NHibernate.Util.ADOExceptionReporter >>> - Could not execute query >>> [ SQL not available ] >>> >>> System.NullReferenceException: Object reference not set to an instance >>> of an object. >>> at lambda_method(Closure , Object[] ) >>> at NHibernate.Linq.ResultTransformer.TransformTuple(Object[] tuple, >>> String[] aliases) >>> at NHibernate.Hql.HolderInstantiator.Instantiate(Object[] row) >>> at NHibernate.Loader.Hql.QueryLoader.GetResultList(IList results, >>> IResultTransformer resultTransformer) >>> at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor >>> session, QueryParameters queryParameters) >>> at NHibernate.Loader.Loader.List(ISessionImplementor session, >>> QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) >>> at NHibernate.Loader.Hql.QueryLoader.List(ISessionImplementor >>> session, QueryParameters queryParameters) >>> at >>> NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor >>> session, QueryParameters queryParameters) >>> at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters >>> queryParameters, ISessionImplementor session, IList results) >>> at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, >>> QueryParameters queryParameters, IList results) >>> 2016-03-21 14:36:49,843 [11] WARN NHibernate.Util.ADOExceptionReporter >>> - System.NullReferenceException: Object reference not set to an instance of >>> an object. >>> at lambda_method(Closure , Object[] ) >>> at NHibernate.Linq.ResultTransformer.TransformTuple(Object[] tuple, >>> String[] aliases) >>> at NHibernate.Hql.HolderInstantiator.Instantiate(Object[] row) >>> at NHibernate.Loader.Hql.QueryLoader.GetResultList(IList results, >>> IResultTransformer resultTransformer) >>> at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor >>> session, QueryParameters queryParameters) >>> at NHibernate.Loader.Loader.List(ISessionImplementor session, >>> QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) >>> at NHibernate.Loader.Hql.QueryLoader.List(ISessionImplementor >>> session, QueryParameters queryParameters) >>> at >>> NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor >>> session, QueryParameters queryParameters) >>> at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters >>> queryParameters, ISessionImplementor session, IList results) >>> at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, >>> QueryParameters queryParameters, IList results) >>> 2016-03-21 14:36:49,843 [11] ERROR NHibernate.Util.ADOExceptionReporter >>> - Object reference not set to an instance of an object. >>> 2016-03-21 14:37:02,383 [11] DEBUG NHibernate.AdoNet.ConnectionManager - >>> after autocommit >>> >>> >>> >>> >>> *This is the query of the view the 35 rows come from:* >>> create view vCustomersServicesSets >>> as >>> >>> select >>> ROW_NUMBER() OVER(ORDER BY aa.ServiceRecid DESC) AS >>> 'CustomerServiceSetRecid' <-- is this something nHibernate can't deal >>> with? And if so what can be done? >>> .... >>> , bb.ModifiedByName >>> from >>> ( >>> select >>> a.ServiceRecid >>> ..... >>> , b.CustomerEnabled >>> from vServices a >>> , vCustomers b >>> ) aa >>> left join ...... >>> go >>> >>> >>> >>> >>> >>> *This is my class from the embedded mapping:* >>> <class name ="vCustomersServiceOptions" >>> table="dbo.vCustomersServicesSets" dynamic-update="true"> >>> <cache usage="read-only"/> >>> <id name="CustomerServiceSetRecid" column="CustomerServiceSetRecid" >>> type="int"> >>> <generator class="native" /> >>> </id> >>> <property name="DataEntryRowDisabled" /> >>> ....... >>> <property name="ModifiedByName" /> >>> </class> >>> >>> >>> *What do I do?* >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to nhusers+u...@googlegroups.com <javascript:>. >> To post to this group, send email to nhu...@googlegroups.com >> <javascript:>. >> Visit this group at https://groups.google.com/group/nhusers. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+unsubscr...@googlegroups.com. To post to this group, send email to nhusers@googlegroups.com. Visit this group at https://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.