I'm afraid the composite key generation is a bit more complex than just overriding the classNameToCompositeIdName, which only changes the
name of the composite id.
From a casual observation of the id.hbm.ftl template, if the class under inspection:
1) does not have an embedded identifier (true for all reverse engineering using the JDBCBinder as far as I can tell, only the HbmBinder has a facility to set the embedded flag on a component), and
2) the composite property is not a component
then it will fall through to the following Freemarker code in the id.hbm.ftl template:
Code:
<composite-id
name="${property.name}"
class="${property.value.getComponentClassName()}"
<#if c2h.isUnsavedValue(property)>
unsaved-value="${c2h.getUnsavedValue(property)}"
</#if>
<#if !property.basicPropertyAccessor>
access="${property.propertyAccessorName}"
</#if>
>
<#foreach keyproperty in property.value.propertyIterator>
<#if !c2h.isManyToOne(keyproperty)>
<key-property name="${keyproperty.name}" type="${keyproperty.value.typeName}">
<#foreach column in keyproperty.columnIterator>
<#include "pkcolumn.hbm.ftl">
</#foreach>
</key-property>
<#else>
<key-many-to-one name="${keyproperty.name}" class="${c2j.getJavaTypeName(keyproperty, false)}">
<#foreach column in keyproperty.columnIterator>
<#include "pkcolumn.hbm.ftl">
</#foreach>
</key-many-to-one>
</#if>
</#foreach>
</composite-id>
It looks like the easiest way to do what you want is to modify the id.hbm.ftl Freemarker template, replacing the above code thusly:
Code:
<composite-id
<#if c2h.isUnsavedValue(property)>
unsaved-value="${c2h.getUnsavedValue(property)}"
</#if>
<#if !property.basicPropertyAccessor>
access="${property.propertyAccessorName}"
</#if>
>
<#foreach keyproperty in property.value.propertyIterator>
<#if !c2h.isManyToOne(keyproperty)>
<key-property name="${keyproperty.name}" type="${keyproperty.value.typeName}">
<#foreach column in keyproperty.columnIterator>
<#include "pkcolumn.hbm.ftl">
</#foreach>
</key-property>
<#else>
<key-many-to-one name="${keyproperty.name}" class="${c2j.getJavaTypeName(keyproperty, false)}">
<#foreach column in keyproperty.columnIterator>
<#include "pkcolumn.hbm.ftl">
</#foreach>
</key-many-to-one>
</#if>
</#foreach>
</composite-id>
If you need some more information on how to accoplish this task, perhaps my post in
this thread will help. Now I'm no expert in composite keys (never use them - we recently clean slated our existing tables and all new tables are 1st normal form), and perhaps Max would have more insight when he checks in, but at the least, this will work in the interim.