I hate Hibernate PropertyAccessException!
So I recently changed around some of my hibernate mapping fields around; moving properties from specific subclass to the superclass, and all of a sudden the app broken with the following error:
org.hibernate.PropertyAccessException: could not set a field value by reflection setter of uk.ac.warwick.sbr.BinaryPageImpl.escapeHtml
at
org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:81)
This was puzzling because all my unit tests worked, and the setter was definately available.
The problem was that there was a null in the database for the field, for the row I was working on, and it was complaining (correctly) that it cannot set a null against a boolean.
If only the error message had included the value it was trying to set :) Just another example of Hibernates error messages being absolutely correct and entirely unhelpful :)
27 comments by 1 or more people
[Skip to the latest comment]Amita
hey,
ur blog was a pick by luck and i am surely lucky.
Thanks so much for this.
04 Aug 2005, 08:23
Chad
I love you.
12 Aug 2005, 17:45
Eyak
Hibernate is a bitch – gets you where you need but if you get stuck, you're in a jam to say the least, with the lacking help docs and those detailed error msgs (NOT)..looks like we have a lot work ahead of us.
06 Nov 2005, 15:09
Saurabh
painful exception but your blog was helpful.
05 Apr 2006, 07:13
Mark
Just saved me a few hours … thanks
13 Apr 2006, 22:14
ondrej
praises Colin and the almighty Google
27 Apr 2006, 18:44
allen
Praise be. This little post saved me many hours or torment. If only I'd looked sooner…
05 May 2006, 14:30
Ramon
You don't know Hibernate…
13 May 2006, 18:48
Adrian
ta
06 Jun 2006, 10:47
Bryan
Thank you, Colin! I'd added a new boolean column to a table and was getting this error (the existing records had "null" in the new column). Google brought me here; a simple SQL update statement later and the code worked without adjustment!
Ignore 12–year–old AOL 'haxxors' who say you don't know Hibernate — they're just mad because mommie made them stop playing WoW and take out the trash. Poo Poo.
Cheers,
Bryan
25 Jun 2006, 21:29
ZieNie
Great…..
that's It~
Thank You. U save my TIME ^^
28 Jun 2006, 08:45
masha
I had this exception too. after trecking it out for a day, i found out that i forgot to add sort="natural" into the definition of map (witch i declared in code as SortedMap). Be aware:)
10 Jul 2006, 11:08
Nick Howes
I got this exception, though it turned out I just had completely the wrong classname in the class attribute :) That’ll teach me to copy-and-paste…
08 Sep 2006, 14:51
Vibhor
Ooops , that saved a hell lot of debugging for me .. :D
14 Sep 2006, 06:31
blah blah
Thank you…Saved me lots of time too….Damn, SpringFramework Support guys are clueless
29 Sep 2006, 19:01
TotMacher
Thanks for this info. Saved me a lot of time!
Hibernate should really give some more information about the problem in theier exception texts!
Regards,
tot
05 Oct 2006, 13:53
rakesh
thanks A lot
07 Dec 2006, 09:46
Menapace
You have save one more life !
1 minute more and I will been crazy !
10 Feb 2007, 17:56
gman
Yes, thank you very much.
Fortunately I have learned to google error message quite fast after they occur, so I didn’t stuck with this for long. But if it wasn’t for you, I would go crazy and lay down deep in the forest and just… well, I wouldn’t come back to say it that way.
22 Feb 2007, 08:59
Harshinie
thank you very much for the tip. this saves lots of ou time.:)
13 Mar 2007, 07:11
vijay
Thanks saved me time
20 Mar 2007, 17:54
parkash
Thanks! You saved me lots of time :D
17 Apr 2007, 13:19
Prashanth
Thank You.. It was helpful…
24 Jul 2007, 06:38
Daniel D
thanks! You just saved 2 hours of my work:)
13 Aug 2007, 13:14
Dirk H
saved my time, but i rather used the description on http://www.hibernate.org/hib_docs/v3/api/org/hibernate/PropertyAccessException.html
the primitive datatype (was null) was my exception cause. changed long to Long and this did it for me.
greetings from germany
16 Aug 2007, 10:52
Mike E.
Ty. Not directly helpful for my problem, but pointed me in the right direction. You will also get this non-helpful error message if you do a collection mapping on a field declared as HashSet instead of Set.
i.e. private HashSet someSet; vs private Set someSet;
13 Sep 2007, 00:32
Maaz Hurzuk
Thanks mate ….. This blog was really helpful.
23 Oct 2007, 15:26
Add a comment
You are not allowed to comment on this entry as it has restricted commenting permissions.