mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
规范表名
This commit is contained in:
@@ -1,22 +1,26 @@
|
||||
package cn.lihongjie.coal.config;
|
||||
|
||||
import org.hibernate.boot.ResourceStreamLocator;
|
||||
import org.hibernate.boot.spi.*;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy;
|
||||
import org.hibernate.boot.model.naming.Identifier;
|
||||
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
|
||||
import org.hibernate.boot.spi.AdditionalMappingContributions;
|
||||
import org.hibernate.boot.spi.AdditionalMappingContributor;
|
||||
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.sql.SQLType;
|
||||
|
||||
@Configuration
|
||||
public class HibernateConfig {
|
||||
|
||||
|
||||
@Bean
|
||||
AdditionalMappingContributor metadataContributor(){
|
||||
AdditionalMappingContributor metadataContributor() {
|
||||
|
||||
return new AdditionalMappingContributor() {
|
||||
@Override
|
||||
@@ -32,9 +36,25 @@ public class HibernateConfig {
|
||||
.addDescriptor(SqlTypes.VARCHAR, new DdlTypeImpl(SqlTypes.VARCHAR, "text", new PostgreSQLDialect()));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public PhysicalNamingStrategy physicalNamingStrategy() {
|
||||
|
||||
return new CamelCaseToUnderscoresNamingStrategy() {
|
||||
|
||||
@Override
|
||||
public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
|
||||
|
||||
return super.toPhysicalTableName(new Identifier("t_" + logicalName.getText().replace("Entity", ""),
|
||||
logicalName.isQuoted()),
|
||||
jdbcEnvironment);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
public class OrganizationEntity extends CommonEntity {
|
||||
|
||||
|
||||
@OneToMany
|
||||
@OneToMany(mappedBy = "parent")
|
||||
@JsonManagedReference
|
||||
private List<OrganizationEntity> children;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ResourceEntity extends CommonEntity {
|
||||
private List<PermissionEntity> permissions;
|
||||
|
||||
|
||||
@OneToMany
|
||||
@OneToMany(mappedBy = "parent")
|
||||
@JsonManagedReference
|
||||
private List<ResourceEntity> children;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user