-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: sql-query problem where properties mapped to formula
PostPosted: Mon Jun 07, 2010 7:36 am 
Beginner
Beginner

Joined: Wed Oct 18, 2006 4:41 am
Posts: 20
Location: West Yorkshire, UK
Hi there,

I am using an sql-query for an optimised search routine. Unfortunately it does not run correctly when one of my fields is mapped to a formula. I get the following exception:

Value cannot be null. Parameter name: fieldName
Code:
   at System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName)
   at System.Data.SqlClient.SqlDataReader.GetOrdinal(String name)
   at NHibernate.Driver.NHybridDataReader.GetOrdinal(String name)
   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.Persister.Entity.AbstractEntityPersister.Hydrate(IDataReader rs, Object id, Object obj, ILoadable rootLoadable, String[][] suffixedPropertyColumns, Boolean allProperties, ISessionImplementor session)
   at NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i, Object obj, String instanceClass, EntityKey key, String rowIdAlias, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session)
   at NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, EntityKey key, LockMode lockMode, String rowIdAlias, 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)


<property name="PropertyName" formula="(SELECT p.Property FROM vProperties p WHERE p.ID = ID)" />

If I return data using criteria objects this property does not cause an error.

I have seen other forum posts describing the same behaviour but sadly without a resolution - any help would be gratefully received.

My query is mapped as follows:

Code:
  <sql-query name="objectSearch" callable="true">
    <return class="Object"/>
     exec pCaseSearch :ObjectIDs, :SearchTerm
  </sql-query>


Thanks, Carl


Top
 Profile  
 
 Post subject: Re: sql-query problem where properties mapped to formula
PostPosted: Tue Jul 20, 2010 5:51 am 
Newbie

Joined: Tue Mar 09, 2010 11:30 am
Posts: 7
Hi there,
Did you manage to resolve this, Im getting the same issue!


Top
 Profile  
 
 Post subject: Re: sql-query problem where properties mapped to formula
PostPosted: Tue Jul 20, 2010 5:58 am 
Beginner
Beginner

Joined: Wed Oct 18, 2006 4:41 am
Posts: 20
Location: West Yorkshire, UK
No I'm afraid not. I had to change the way I work....

I have a view that calculates what was being calculated in the formula - this is mapped to a class that is used as a property on the parent class.

Thanks, Carl


Top
 Profile  
 
 Post subject: Re: sql-query problem where properties mapped to formula
PostPosted: Tue Jul 20, 2010 7:06 am 
Newbie

Joined: Tue Mar 09, 2010 11:30 am
Posts: 7
thanks Carl, ill probably have to do the same, have been pulling my hair out over this for days!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.