xc
2020-12-04 80b88f63ec734fceba41bf6c3bb2ffb201e3b05b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.hbbh.adapter.config;
 
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
import org.springframework.stereotype.Component;
 
/**
 * init
 * re table name
 */
public class Strategy extends SpringPhysicalNamingStrategy
{
 
    private String tableName="unknow";
    public String getTableName() {
        return tableName;
    }
    public void setTableName(String tableName) {
        this.tableName = tableName;
    }
    /**
     * 自定义表名转换
     * @param name
     * @param jdbcEnvironment
     * @return
     */
    @Override
    public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
        String tableName = getTableName();
        return Identifier.toIdentifier(tableName);
    }
}