2009-07-10

Hibernate & case sensitivity table names

To manage case sensitivity tables and key strategy in hibernate + spring you should use hibernate NamingStrategy implementation.






...




org.hibernate.dialect.MySQL5Dialect
thread
org.hibernate.transaction.JDBCTransactionFactory



<bean class="a.b.c.CustomNamingStrategy" />





a.b.c.CustomNamingStrategy should implements NamingStrategy or extends already existed implementations
- DefaultNamingStrategy
- ImprovedNamingStrategy
- ..



public class CustomNamingStrategy extends DefaultNamingStrategy {

@Override
public String classToTableName(String className) {
return super.classToTableName(className).toLowerCase();
}

....
}

No comments: