Browse Source
Merge in CORE/base-third from ~ELIJAH/base-third:release/10.0 to release/10.0 * commit '55d87f160e59415099bd554902329f0e71e76120': DEC-14578 feat: hibernate二级缓存卡顿 DEC-14578 feat: hibernate自动删除旧唯一键 DEC-14578 feat: 使hibernate支持主键的自动更新 DEC-14578 feat: 去掉无用的jetbrain.NotNull依赖, 拆分Utils方法 QFX-1737 fix:数据上传之后报错 DEC-14578 打包脚本 DEC-14578 引入com.alibaba:transmittable-thread-localrelease/10.0
Elijah
4 years ago
13 changed files with 259 additions and 10 deletions
@ -0,0 +1,23 @@
|
||||
package com.fr.third.org.hibernate.dialect.unique; |
||||
|
||||
import com.fr.third.org.hibernate.dialect.Dialect; |
||||
|
||||
/** |
||||
* @author Andrea Boriero |
||||
*/ |
||||
public class MySQLUniqueDelegate extends DefaultUniqueDelegate { |
||||
|
||||
/** |
||||
* Constructs MySQLUniqueDelegate |
||||
* |
||||
* @param dialect The dialect for which we are handling unique constraints |
||||
*/ |
||||
public MySQLUniqueDelegate(Dialect dialect) { |
||||
super( dialect ); |
||||
} |
||||
|
||||
@Override |
||||
protected String getDropUnique() { |
||||
return " drop index "; |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.fr.third.org.hibernate.tool.schema.internal; |
||||
|
||||
import com.fr.third.org.hibernate.boot.Metadata; |
||||
import com.fr.third.org.hibernate.dialect.Dialect; |
||||
import com.fr.third.org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; |
||||
import com.fr.third.org.hibernate.mapping.Column; |
||||
import com.fr.third.org.hibernate.mapping.PrimaryKey; |
||||
import com.fr.third.org.hibernate.tool.schema.spi.Exporter; |
||||
|
||||
import java.util.Iterator; |
||||
|
||||
/** |
||||
* @author Elijah |
||||
* @version 10.5 |
||||
* Created by Elijah on 2020/9/30 |
||||
*/ |
||||
public class StandardPrimaryKeyExporter implements Exporter<PrimaryKey> { |
||||
private Dialect dialect; |
||||
|
||||
public StandardPrimaryKeyExporter(Dialect dialect) { |
||||
this.dialect = dialect; |
||||
} |
||||
|
||||
@Override |
||||
public String[] getSqlCreateStrings(PrimaryKey primaryKey, Metadata metadata) { |
||||
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment(); |
||||
final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format( |
||||
primaryKey.getTable().getQualifiedTableName(), |
||||
dialect |
||||
); |
||||
|
||||
final String constraintName = dialect.quote( primaryKey.getName() ); |
||||
return new String[]{ "alter table " + tableName + dialect.getAddPrimaryKeyConstraintString(constraintName) + " " + columnsToString( primaryKey ) }; |
||||
} |
||||
|
||||
protected String columnsToString(PrimaryKey primaryKey) { |
||||
final StringBuilder sb = new StringBuilder(); |
||||
sb.append( " (" ); |
||||
final Iterator<Column> columnIterator = primaryKey.columnIterator(); |
||||
while ( columnIterator.hasNext() ) { |
||||
final Column column = columnIterator.next(); |
||||
sb.append( column.getQuotedName( dialect ) ); |
||||
if ( columnIterator.hasNext() ) { |
||||
sb.append( ", " ); |
||||
} |
||||
} |
||||
|
||||
return sb.append( ')' ).toString(); |
||||
} |
||||
|
||||
@Override |
||||
public String[] getSqlDropStrings(PrimaryKey primaryKey, Metadata metadata) { |
||||
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment(); |
||||
final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format( |
||||
primaryKey.getTable().getQualifiedTableName(), |
||||
dialect |
||||
); |
||||
final StringBuilder buf = new StringBuilder( "alter table " ); |
||||
buf.append( tableName ); |
||||
buf.append(dialect.getDropPrimaryKeyConstraintString(dialect.quote( primaryKey.getName()))); |
||||
return new String[] { buf.toString() }; |
||||
} |
||||
} |
Loading…
Reference in new issue