I'd like to add something to this issue. I also regard it as Blocking, so I spent some time creating a NamingStrategy since I want to use an existing datamodel.
This all went a LOT easier then I expected.
First, I created a NamingStrategy based on this blog, extending the ImprovedNamingStrategy (which almost matches my datamodel wishes).
/**
* {@inheritDoc}
*/
@Override
public String tableName(final String tableName) {
final String renamedTableName;
if (tableName.endsWith(MOD4J_DEFAULT_TABLE_SUFFIX)) {
renamedTableName = tableName.replaceAll(MOD4J_DEFAULT_TABLE_SUFFIX, "");
} else {
renamedTableName = tableName;
}
return super.tableName(renamedTableName);
}
This effectively removes the _TABLE, which is just one example of course. In my case, the datamodel contains some abbreviations (_ind instead of _indication for example) that I also put in there. Next, I modified the applicationContextBase.xml (which gets overridden next time I touch a model of course).
<bean class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" id="sessionFactory">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="namingStrategy" ref="namingStrategy" />
<property name="mappingResources">
(....)
<bean id="namingStrategy" class="nl.x.y.data.hibernate.mapping.JobportalNamingStrategy" />
A very quick fix here would be to introduce a property allowing the classname of a namingStrategy to be specified which is default set to the Hibernate DefaultNamingStrategy (or rather the ImprovedNamingStrategy, cause CamelCase in database tables and columns is ugly!
). This allows a great deal more flexibility.
Also, in the hbm.xml, the table or column names should no longer be generated (since it's not needed, configuration by exception). This might also fix the bug MODFORJ-124!
Since this is a really small fix solving a really large issue I think it should be done ASAP 
Note: In my opinion, this doesn't mean the hbm.xml shouldn't be made editable in some way in the future, since NamingStratregies only apply to rules that apply to the whole datamodel. It's not uncommon to have one or a few columns break the normal rules, because of history, other applications using the tables, etc etc. You don't want to hardcode that kind of stuff in the NamingStrategy, but rather specify the column name in the hbm.xml (configuration by exception).
I'd like to add something to this issue. I also regard it as Blocking, so I spent some time creating a NamingStrategy since I want to use an existing datamodel.
This all went a LOT easier then I expected.
First, I created a NamingStrategy based on this blog, extending the ImprovedNamingStrategy (which almost matches my datamodel wishes).
/** * {@inheritDoc} */ @Override public String tableName(final String tableName) { final String renamedTableName; // FIXME remove once mod4j default is no longer _TABLE if (tableName.endsWith(MOD4J_DEFAULT_TABLE_SUFFIX)) { renamedTableName = tableName.replaceAll(MOD4J_DEFAULT_TABLE_SUFFIX, ""); } else { renamedTableName = tableName; } return super.tableName(renamedTableName); }This effectively removes the _TABLE, which is just one example of course. In my case, the datamodel contains some abbreviations (_ind instead of _indication for example) that I also put in there. Next, I modified the applicationContextBase.xml (which gets overridden next time I touch a model of course).
A very quick fix here would be to introduce a property allowing the classname of a namingStrategy to be specified which is default set to the Hibernate DefaultNamingStrategy (or rather the ImprovedNamingStrategy, cause CamelCase in database tables and columns is ugly!
). This allows a great deal more flexibility.
Also, in the hbm.xml, the table or column names should no longer be generated (since it's not needed, configuration by exception). This might also fix the bug
MODFORJ-124!Since this is a really small fix solving a really large issue I think it should be done ASAP
Note: In my opinion, this doesn't mean the hbm.xml shouldn't be made editable in some way in the future, since NamingStratregies only apply to rules that apply to the whole datamodel. It's not uncommon to have one or a few columns break the normal rules, because of history, other applications using the tables, etc etc. You don't want to hardcode that kind of stuff in the NamingStrategy, but rather specify the column name in the hbm.xml (configuration by exception).