July 01, 2005

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 Not publicly viewable

[Skip to the latest comment]
  1. Amita

    hey,
    ur blog was a pick by luck and i am surely lucky.
    Thanks so much for this.

    04 Aug 2005, 08:23

  2. Chad

    I love you.

    12 Aug 2005, 17:45

  3. 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

  4. Saurabh

    painful exception but your blog was helpful.

    05 Apr 2006, 07:13

  5. Mark

    Just saved me a few hours … thanks

    13 Apr 2006, 22:14

  6. ondrej

    praises Colin and the almighty Google

    27 Apr 2006, 18:44

  7. allen

    Praise be. This little post saved me many hours or torment. If only I'd looked sooner…

    05 May 2006, 14:30

  8. Ramon

    You don't know Hibernate…

    13 May 2006, 18:48

  9. Adrian

    ta

    06 Jun 2006, 10:47

  10. 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

  11. ZieNie

    Great…..

    that's It~

    Thank You. U save my TIME ^^

    28 Jun 2006, 08:45

  12. 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

  13. 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

  14. Vibhor

    Ooops , that saved a hell lot of debugging for me .. :D

    14 Sep 2006, 06:31

  15. blah blah

    Thank you…Saved me lots of time too….Damn, SpringFramework Support guys are clueless

    29 Sep 2006, 19:01

  16. 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

  17. rakesh

    thanks A lot

    07 Dec 2006, 09:46

  18. Menapace

    You have save one more life !
    1 minute more and I will been crazy !

    10 Feb 2007, 17:56

  19. 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

  20. Harshinie

    thank you very much for the tip. this saves lots of ou time.:)

    13 Mar 2007, 07:11

  21. vijay

    Thanks saved me time

    20 Mar 2007, 17:54

  22. parkash

    Thanks! You saved me lots of time :D

    17 Apr 2007, 13:19

  23. Prashanth

    Thank You.. It was helpful…

    24 Jul 2007, 06:38

  24. Daniel D

    thanks! You just saved 2 hours of my work:)

    13 Aug 2007, 13:14

  25. 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

  26. 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

  27. 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.

Trackbacks

July 2005

Mo Tu We Th Fr Sa Su
Jun |  Today  | Aug
            1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Search this blog

Tags

Galleries

Most recent comments

  • Interesting… While I'm not completely convinced in such microbenchmarks, I'm pretty sure that 1ms = … by Alexander Snaps on this entry
  • Hello. I bought the book yesterday. I was trying to find the source code for chapter 11 and chapter … by Suleman on this entry
  • http://woosight.net/account/login?username=demo by live mashup demo on this entry
  • Thanks mate .. This blog was really helpful. by Maaz Hurzuk on this entry
  • Ty. Not directly helpful for my problem, but pointed me in the right direction. You will also get th… by Mike E. on this entry

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXIV