Wrong NamingStrategy methods called

Description

I believe this is the actual problem that the submitter of bug https://hibernate.atlassian.net/browse/HHH-318#icft=HHH-318 was running into: the Hibernate core code appears to call the wrong methods on the NamingStrategy object.

I just wrote a custom strategy and as a test, removed some of the column mappings from my mapping documents. I expected my propertyToColumnName() method to be called for the properties whose column mappings I'd just removed, and my columnName() method to be called on the ones whose mappings were still specified.

Instead, Hibernate called columnName() for all the properties, passing in the mapped column name for those properties that were listed in the mapping document and passing in the raw property name for the unmapped properties.

It appears propertyToColumnName() is never called at all.

Working around this bug is why ImprovedNamingStrategy does its underscore conversion in columnName() and tableName(), which of course it shouldn't have to do since the underscore insertion is a way to map property/class names to columns, not a modification to apply to existing column names. That's the cause of HHH-318.

Activity

Max Rydahl AndersenMay 7, 2005 at 8:09 PM

open separate issue if you consider it a bug and with an example (coz i don't think there is a bug there)

Steven GrimmMay 7, 2005 at 8:02 PM

However, ImprovedNamingStrategy is still wrong. It shouldn't be adding underscores to column names specified in the mapping document.

Steven GrimmMay 7, 2005 at 7:56 PM

Oops! Now I see the problem. It is not a bug in Hibernate at all, but in XDoclet, which I'm using to generate my mappings. It seems XDoclet is including a "column=" attribute in the <property> tag no matter what, and is setting the value to the field name if a column name isn't explicitly specified.

Hopefully this comment will be of help to someone else.

Rejected

Details

Assignee

Reporter

Components

Affects versions

Priority

Created May 7, 2005 at 7:46 PM
Updated May 7, 2005 at 8:09 PM
Resolved May 7, 2005 at 7:59 PM

Flag notifications