Register  |  Login



Earn money by sharing your knowledge through Quomon's revenue sharing program

Question

Status: Closed Points: 200 Time: 08:16 - Sep 29, 2008  

dustPuppy

Value cannot be null. Parameter name: fieldName error in NHibernate formula

Hi,

I am getting this error after I added a formula to a class: Value
cannot be null. Parameter name: fieldName
The formula is:
<property name="AnswersCount" formula="(SELECT COUNT(A.postid) FROM
Answerpost as A WHERE A.Userid = id)" insert="false" type="Int32" />
I suppose that it's because the formula returns null, but I can't find
a way to get around it.

I'd appreciate any help or directions...

Answer Discussion
Tutorials

 

Q&A System for Websites and Corporate Collaboration

Advertisement

  • Generates significant organic traffic for websites
  • Saves companies money, resources, and time

nidhi

Date:: Sep 29, 2008

Time:: 18:31

Im currently using Hibernate with Spring in Java. Now I know you are using asp.net but the basic concepts should be the same.

The hibernate queries I use reference a class, and we have hibernate mapping (xml) files that map variables inside a class to a column in the table

It looks like you got normal sql, I wonder if you need to use it as Hibernate expects?

I do not use formula's like you do as Ive coded it with the class querying. XML files simply used to map (*.hbm.xml)

dustPuppy

Date:: Sep 30, 2008

Time:: 05:41

Hi Nidhi,
As far as I've read formulas have to be sql, hql won't work there.
But I figured out what the problem was. In this particular case I had created a sql query instead of using the hql, in order to get a particular result set of the user class that this formula is part of. So the sql was not adding the AnswersCount "virtual" property and that was why it was giving an error.

Question Answered

This question has been closed, and points have been rewarded to the following experts:

dustPuppy: 200

You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

No tutorials have been submitted yet. Want to be the first?

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top NHibernate Experts

View More

Rank

Expert

Points

1.

nidhi

55

2.

Sergio Costa

25

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es