Why does the NamingStrategy methods still get called when the table/column property is explicitly set? Here is the behaivor I am seeing using the ImprovedNamingStrategy
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.yahoo.pm.persist.pm" schema="PMCAPS20>
<class name="SvrRole" mutable="false">
<cache usage="read-only"/>
<id name="SvrRoleId"/>
<property name="Name" />
<property name="SvrRoleDescription" >
<column name="SVR_ROLE_DESC"/>
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
List roles = session.createQuery("from SvrRole").list();
The generated SQL (show_sql=true):
10:33:05,934 INFO [STDOUT] Hibernate: select svrrole0_.svr_role_id as svr1_, svrrole0_.name as name6_, svrrole0_.sv_r_rol_e_desc as sv3_6_ from PMCAPS20.svr_role svrrole0_
The primary thing to note is that I want to have a different property name for SvrRoleDescription than the actual column name SVR_ROLE_DESC. Intuition tells me that it should take the column name verbatum if I supply it BUT it actually tries to apply the ImprovedNamingStrategy and it ends up munging the column name to sv_r_rol_e_desc. I looked at the source code and found that it is in fact utilizing the NamingStrategy directly on the column name. This doesn't seem right to me. Am I misunderstanding the role of NamingStrategy?
|