📄 cenamingstrategy.java
字号:
package org.hibernate.auction.persistence;
import net.sf.hibernate.cfg.NamingStrategy;
import net.sf.hibernate.util.StringHelper;
/**
* Prefix database table and column names with a CaveatEmptor handle.
* <p>
* This is the implementation of a Hibernate <tt>NamingStrategy</tt>.
* Hibernate calls this class whenever it creates the database schema.
* All table names are prefixed with "CE_" while keeping the
* default Hibernate of uppercase property names. To enable this strategy,
* set it as the default for the <tt>SessionFactory</tt> , eg. in
* <tt>HibernateUtil</tt>:
* <p>
* <pre>
* configuration = new Configuration();
* configuration.setNamingStrategy(new CENamingStrategy());
* sessionFactory = configuration.configure().buildSessionFactory();
*
* </pre>
* In general, <tt>NamingStrategy</tt> is a powerful concept that gives
* you freedom to name your database tables and columns using whatever
* pattern you like.
*
* @see HibernateUtil
* @author Christian Bauer <christian@hibernate.org>
*/
public class CENamingStrategy implements NamingStrategy {
public String classToTableName(String className) {
return StringHelper.unqualify(className);
}
public String propertyToColumnName(String propertyName) {
return propertyName;
}
public String tableName(String tableName) {
return "CE_" + tableName;
}
public String columnName(String columnName) {
return columnName;
}
public String propertyToTableName(String className, String propertyName) {
return "CE_"
+ classToTableName(className)
+ '_'
+ propertyToColumnName(propertyName);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -