1.在实体上使用@Table 注解 默认不加使用驼峰转下划线匹配
@Table(name="table_name")
public class Entity{
}
2.实现 IDynamicTableName 接口
public class Entity implements IDynamicTableName{
@Override
public String getDynamicTableName() {
return “tableName”;
}
}
可以直接添加一个非数据库字段 使用 @Transient 注解 外部直接设置表名
@Transient
private String tableName;
@Override
public String getDynamicTableName() {
return tableName;
}
IDynamicTableName 源码定义:
/*
- The MIT License (MIT)
- Copyright (c) 2014-2017 abel533@gmail.com
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, mer