日期:2014-05-19 浏览次数:20704 次
public class YourNamingStrategy extends ImprovedNamingStrategy {
//以下方法全部可以自定义
public String classToTableName(String className) {
return StringHelper.unqualify(className);
}
public String propertyToColumnName(String propertyName) {
return propertyName;
}
public String tableName(String tableName) {
return tableName;
}
public String columnName(String columnName) {
return columnName;
}
public String propertyToTableName(String className, String propertyName) {
return classToTableName(className) + '_'
+ propertyToColumnName(propertyName);
}
}
Configuration cfg = new Configuration();
cfg.setNamingStrategy( new MyNamingStrategy() );
SessionFactory sessionFactory sf = cfg.configure().buildSessionFactory();