Java Chatter and Random Nagging

Wednesday, May 09, 2007

Crazy Hibernate Error Messages

It could be because of my limited knowledge of Hibernate, but Hibernate's error messages are a real mystery to me. For a framework, so widely accepted by both the community and the industry, I find their error messages shown to the user (programmer) very disturbing. My latest problem had everything to do with the following error:

org.springframework.orm.hibernate3.HibernateSystemException: could not set a field value by reflection setter of hrutil.model.Employee.workYears; nested exception is org.hibernate.PropertyAccessException: could not set a field value by reflection setter of hrutil.model.Employee.workYears

Not an easy one, I'll tell you. Yesterday, I've surfed the internet for about half an hour and still nothing so I went to sleep with this "unsatisfied programming problem" feeling. After some trial-and-error, I finally found my problem in the mapping file. It appeared that workYears was a SortedSet and I forgot to add sort="natural " to the workYears property.

<set name="workYears" lazy="true" cascade="all-delete-orphan" table="EMPLOYEES_WORKYEARS" sort="natural">

It works like a dream again now, but with error messages like this, something tells me that it won't be long till my next Hibershite (as a former colleague called it) frustration shows.


At 5:38 pm, Anonymous Anonymous said...

I just got the same error message and came across your blog, I prefer to think of them as Hibernightmares.



Post a Comment

<< Home