Browsing this Thread:   1 Anonymous Users






springboot jpa 表前缀
#1
Just can't stay away
Just can't stay away


See User information
jpa 添加 表前缀

package my.app;

import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;

public class 
PrefixPhysicalNamingStrategy extends PhysicalNamingStrategyStandardImpl {

    
/**
     * TODO Make this an injectable application property
     */
    
public static final String TABLE_NAME_PREFIX "MY_PREFIX_";

    @
Override
    
public Identifier toPhysicalTableName(Identifier nameJdbcEnvironment context) {
        
Identifier newIdentifier = new Identifier(TABLE_NAME_PREFIX name.getText(), name.isQuoted());
        return 
super.toPhysicalTableName(newIdentifiercontext);
    }
}



application.properties

spring.jpa.hibernate.naming.physical-strategy=my.app.PrefixPhysicalNamingStrategy


Posted on: 2021/11/1 15:14
Top








friend links
Themes

(2 themes)
Login
Username:

Password:


Lost Password?
Register now!
Categories
Xoops (11)
--Modules (2)
--Themes (0)
Article (8)