http://apps.hi.baidu.com/share/detail/52077567

http://apps.hi.baidu.com/share/detail/52077567

 

项目中遇到需要修改反转过来的实体名称及存放路径

 

import java.util.List;

import org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.ReverseEngineeringSettings;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.TableIdentifier;

 

 

public class MyStrategy extends DelegatingReverseEngineeringStrategy {

 public MyStrategy(ReverseEngineeringStrategy delegate) {
  super(delegate);
 }
 
  public String columnToPropertyName(TableIdentifier table, String
  columnName) {
  return super.columnToPropertyName(table, columnName);
  }
   public String tableToClassName(TableIdentifier tableIdentifier) {
   String className = super.tableToClassName(tableIdentifier);
   className=className.replaceAll("cc", "");
   return firstToUpperCase(className);
   }
  private String firstToUpperCase(String s) {
  return s.substring(0, 1).toLowerCase() + s.substring(1);
  }
  public void setSettings(ReverseEngineeringSettings settings) {
  super.setSettings(settings);
  settings.setDefaultPackageName("c.domain");
  }
}

你可能感兴趣的:(baidu)