I'm seeing the same thing. Hibernate 2.1.7c, Firebird 1.5.2
What version of Hibernate are you using? I was curious if 3.0 fixed this.
Originally, someone was working through our code to fix things that didn't adhere to our coding standards. They prepended the '_' to all the member variable names but didn't touch the .hbm.xml files, and then didn't run any of our integration tests, so a week or so later when we started getting "foreign key constraint violation" all over the place we didn't know why. So I started backing out changes until it worked and voila it was the underscores.
Today I tried adding the underscores in the .hbm.xml files and got:
Code:
net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property _id in class com.lexmark.workflow.framework.domain.printer.ApplicationsFeature
So far I've tried:
- Change the getter/setter names to get_id()/set_id(). It can't be get_Id(), because apparenly the 'upcase the first letter' applies to the underscore rather than the 'i'. Ugly and the changes ripple, but it seemed to be working to a point. I didn't pursue it because of the inherent ugliness. It sounds like you have a large code base and you don't want to be going through it all.
- Specify access="field" for all of the properties in the mapping flies, so that Hibernate doesn't use the getters/setters at all. I suppose there could be cases where some synthesis or validation of the field should be happening and you would lose that. I tried it anyway and it broke on a joined-subclass - it said it couldn't find the _id in the subclass. I guess somehow when it calls the getter it picks up the base-class getter, but in the case of field access its not.
- Page 80 of _Hibernate in Action_ says you can write your own custom PropertyAccessor, but I haven't tried that one. Not sure what package it would have to go in, etc...
- I think for us the simplest thing is to change our coding standards, since we're early in our project. Before I go there I'm going to try creating a PropertyAccessor, though.
-Jeff