I am using org.hibernate.cfg.ImprovedNamingStrategy, But for a table I have specified the table name explicitly
@Table(name="EventLog",schema = "eventlogs")
But hibernate seems to be looking for event_log. Shouldn't explicit naming override the one provided by ImprovedNamingStrategy
If you would like to use the ImprovedNamingStrategy for all tables except those which specify a name explicitly you can use the subclass below. The columnName and tableName methods are the ones called when a name is explicitly specified, this subclass leaves the specified names unmolested.
I think it's odd that this is not the default behaviour.
public class RespectfulImprovedNamingStrategy extends ImprovedNamingStrategy
{
@Override
public String columnName(String columnName)
{
return columnName;
}
@Override
public String tableName(String tableName)
{
return tableName;
}
}
It is the behavior of the org.hibernate.cfg.ImprovedNamingStrategy , which will convert the mixed case names to the embedded underscores name . http://docs.jboss.org/hibernate/core/3.5/api/org/hibernate/cfg/ImprovedNamingStrategy.html . So if you explicitly use the name "EventLog" , it will convert to the "event_log" .
If you simply want to use the name explicitly specified in the @Table
, you should use the org.hibernate.cfg.DefaultNamingStrategy . By default it is used when you instantiate your org.hibernate.cfg.Configuration object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With