Browse Source

Merge pull request #2038 in CORE/base-third from feature/10.0 to feature/x

* commit '55f472d00e09b1ab8581db6e52ca934c0d7414d5':
  无jira任务 docs: 补充readme
  DEC-17895 fix: import fileupload相关类包名错误
  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-local
research/11.0
superman 4 years ago
parent
commit
32cdcdb540
  1. 2
      base-third-project/base-third-step8/pom.xml
  2. 2
      fine-bouncycastle/readme.md
  3. 5
      fine-ehcache/src/main/java/com/fr/third/net/sf/ehcache/pool/builtin-sizeof.filter
  4. 5
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/Dialect.java
  5. 16
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/MySQLDialect.java
  6. 5
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/unique/DefaultUniqueDelegate.java
  7. 23
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/unique/MySQLUniqueDelegate.java
  8. 20
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/IndexInformationImpl.java
  9. 18
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/InformationExtractorJdbcDatabaseMetaDataImpl.java
  10. 2
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/spi/IndexInformation.java
  11. 104
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java
  12. 3
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java
  13. 3
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java
  14. 63
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/StandardPrimaryKeyExporter.java
  15. 4
      fine-spring/src/main/java/com/fr/third/springframework/web/multipart/MultipartFile.java
  16. 24
      fine-spring/src/main/java/com/fr/third/springframework/web/multipart/commons/CommonsFileUploadSupport.java
  17. 8
      fine-spring/src/main/java/com/fr/third/springframework/web/multipart/commons/CommonsMultipartFile.java
  18. 18
      fine-spring/src/main/java/com/fr/third/springframework/web/multipart/commons/CommonsMultipartResolver.java

2
base-third-project/base-third-step8/pom.xml

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.fr.third</groupId> <groupId>com.fr.third</groupId>
<artifactId>base-third</artifactId> <artifactId>base-third</artifactId>
<version>${revision}</version> <version>10.0-FEATURE-SNAPSHOT</version>
</parent> </parent>
<artifactId>step8</artifactId> <artifactId>step8</artifactId>

2
fine-bouncycastle/readme.md

@ -0,0 +1,2 @@
版本:1.64<br>
源码:https://www.bouncycastle.org/latest_releases.html<br>

5
fine-ehcache/src/main/java/com/fr/third/net/sf/ehcache/pool/builtin-sizeof.filter vendored

@ -22,6 +22,11 @@ com.fr.third.org.hibernate.cache.spi.QueryKey.tenantIdentifier
com.fr.third.org.hibernate.engine.spi.TypedValue.type com.fr.third.org.hibernate.engine.spi.TypedValue.type
com.fr.third.org.hibernate.engine.spi.TypedValue.entityMode com.fr.third.org.hibernate.engine.spi.TypedValue.entityMode
# Hibernate 5.x Second Level Entity/Collection Caching
com.fr.third.org.hibernate.cache.internal.CacheKeyImplementation.type
com.fr.third.org.hibernate.cache.internal.CacheKeyImplementation.entityOrRoleName
com.fr.third.org.hibernate.cache.internal.CacheKeyImplementation.tenantId
# This TC internal field is shared amongst all clustered entries # This TC internal field is shared amongst all clustered entries
org.terracotta.cache.serialization.SerializedEntry.tcClazz org.terracotta.cache.serialization.SerializedEntry.tcClazz
com.tc.object.TCObjectSelfImpl.tcClazz com.tc.object.TCObjectSelfImpl.tcClazz

5
fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/Dialect.java

@ -2099,6 +2099,11 @@ public abstract class Dialect implements ConversionContext {
return " add constraint " + constraintName + " primary key "; return " add constraint " + constraintName + " primary key ";
} }
public String getDropPrimaryKeyConstraintString(String constraintName) {
return " drop constraint " + constraintName;
}
/** /**
* Does the database/driver have bug in deleting rows that refer to other rows being deleted in the same query? * Does the database/driver have bug in deleting rows that refer to other rows being deleted in the same query?
* *

16
fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/MySQLDialect.java

@ -22,6 +22,8 @@ import com.fr.third.org.hibernate.dialect.identity.MySQLIdentityColumnSupport;
import com.fr.third.org.hibernate.dialect.pagination.AbstractLimitHandler; import com.fr.third.org.hibernate.dialect.pagination.AbstractLimitHandler;
import com.fr.third.org.hibernate.dialect.pagination.LimitHandler; import com.fr.third.org.hibernate.dialect.pagination.LimitHandler;
import com.fr.third.org.hibernate.dialect.pagination.LimitHelper; import com.fr.third.org.hibernate.dialect.pagination.LimitHelper;
import com.fr.third.org.hibernate.dialect.unique.MySQLUniqueDelegate;
import com.fr.third.org.hibernate.dialect.unique.UniqueDelegate;
import com.fr.third.org.hibernate.engine.spi.RowSelection; import com.fr.third.org.hibernate.engine.spi.RowSelection;
import com.fr.third.org.hibernate.exception.LockAcquisitionException; import com.fr.third.org.hibernate.exception.LockAcquisitionException;
import com.fr.third.org.hibernate.exception.LockTimeoutException; import com.fr.third.org.hibernate.exception.LockTimeoutException;
@ -43,6 +45,8 @@ import com.fr.third.org.hibernate.type.StandardBasicTypes;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class MySQLDialect extends Dialect { public class MySQLDialect extends Dialect {
private final UniqueDelegate uniqueDelegate;
private static final LimitHandler LIMIT_HANDLER = new AbstractLimitHandler() { private static final LimitHandler LIMIT_HANDLER = new AbstractLimitHandler() {
@Override @Override
public String processSql(String sql, RowSelection selection) { public String processSql(String sql, RowSelection selection) {
@ -196,6 +200,8 @@ public class MySQLDialect extends Dialect {
getDefaultProperties().setProperty( Environment.MAX_FETCH_DEPTH, "2" ); getDefaultProperties().setProperty( Environment.MAX_FETCH_DEPTH, "2" );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE ); getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
uniqueDelegate = new MySQLUniqueDelegate( this );
} }
protected void registerVarcharTypes() { protected void registerVarcharTypes() {
@ -234,6 +240,11 @@ public class MySQLDialect extends Dialect {
); );
} }
@Override
public String getDropPrimaryKeyConstraintString(String constraintName) {
return " drop primary key ";
}
@Override @Override
public boolean supportsLimit() { public boolean supportsLimit() {
return true; return true;
@ -422,6 +433,11 @@ public class MySQLDialect extends Dialect {
return ps.getResultSet(); return ps.getResultSet();
} }
@Override
public UniqueDelegate getUniqueDelegate() {
return uniqueDelegate;
}
@Override @Override
public boolean supportsRowValueConstructorSyntax() { public boolean supportsRowValueConstructorSyntax() {
return true; return true;

5
fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/unique/DefaultUniqueDelegate.java

@ -85,7 +85,7 @@ public class DefaultUniqueDelegate implements UniqueDelegate {
final StringBuilder buf = new StringBuilder( "alter table " ); final StringBuilder buf = new StringBuilder( "alter table " );
buf.append( tableName ); buf.append( tableName );
buf.append(" drop constraint " ); buf.append(getDropUnique());
if ( dialect.supportsIfExistsBeforeConstraintName() ) { if ( dialect.supportsIfExistsBeforeConstraintName() ) {
buf.append( "if exists " ); buf.append( "if exists " );
} }
@ -96,4 +96,7 @@ public class DefaultUniqueDelegate implements UniqueDelegate {
return buf.toString(); return buf.toString();
} }
protected String getDropUnique(){
return " drop constraint ";
}
} }

23
fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/unique/MySQLUniqueDelegate.java

@ -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 ";
}
}

20
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/IndexInformationImpl.java

@ -21,12 +21,19 @@ import com.fr.third.org.hibernate.tool.schema.spi.SchemaManagementException;
public class IndexInformationImpl implements IndexInformation { public class IndexInformationImpl implements IndexInformation {
private final Identifier indexIdentifier; private final Identifier indexIdentifier;
private final List<ColumnInformation> columnList; private final List<ColumnInformation> columnList;
private boolean unique;
public IndexInformationImpl(Identifier indexIdentifier, List<ColumnInformation> columnList) { public IndexInformationImpl(Identifier indexIdentifier, List<ColumnInformation> columnList) {
this.indexIdentifier = indexIdentifier; this.indexIdentifier = indexIdentifier;
this.columnList = columnList; this.columnList = columnList;
} }
public IndexInformationImpl(Identifier indexIdentifier, List<ColumnInformation> columnList, boolean unique) {
this.indexIdentifier = indexIdentifier;
this.columnList = columnList;
this.unique = unique;
}
@Override @Override
public Identifier getIndexIdentifier() { public Identifier getIndexIdentifier() {
return indexIdentifier; return indexIdentifier;
@ -37,6 +44,11 @@ public class IndexInformationImpl implements IndexInformation {
return columnList; return columnList;
} }
@Override
public boolean isUnique() {
return unique;
}
public static Builder builder(Identifier indexIdentifier) { public static Builder builder(Identifier indexIdentifier) {
return new Builder( indexIdentifier ); return new Builder( indexIdentifier );
} }
@ -44,6 +56,7 @@ public class IndexInformationImpl implements IndexInformation {
public static class Builder { public static class Builder {
private final Identifier indexIdentifier; private final Identifier indexIdentifier;
private final List<ColumnInformation> columnList = new ArrayList<ColumnInformation>(); private final List<ColumnInformation> columnList = new ArrayList<ColumnInformation>();
private boolean unique;
public Builder(Identifier indexIdentifier) { public Builder(Identifier indexIdentifier) {
this.indexIdentifier = indexIdentifier; this.indexIdentifier = indexIdentifier;
@ -54,13 +67,18 @@ public class IndexInformationImpl implements IndexInformation {
return this; return this;
} }
public Builder setUnique(boolean unique) {
this.unique = unique;
return this;
}
public IndexInformationImpl build() { public IndexInformationImpl build() {
if ( columnList.isEmpty() ) { if ( columnList.isEmpty() ) {
throw new SchemaManagementException( throw new SchemaManagementException(
"Attempt to resolve JDBC metadata failed to find columns for index [" + indexIdentifier.getText() + "]" "Attempt to resolve JDBC metadata failed to find columns for index [" + indexIdentifier.getText() + "]"
); );
} }
return new IndexInformationImpl( indexIdentifier, Collections.unmodifiableList( columnList ) ); return new IndexInformationImpl( indexIdentifier, Collections.unmodifiableList( columnList ), unique);
} }
} }
} }

18
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/InformationExtractorJdbcDatabaseMetaDataImpl.java

@ -710,6 +710,24 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information
} }
try { try {
//处理唯一键
ResultSet uniqueKeyResult = extractionContext.getJdbcDatabaseMetaData().getIndexInfo(catalogFilter, schemaFilter, tableName.getTableName().getText(), true, true);
try {
while (uniqueKeyResult.next()) {
if ( uniqueKeyResult.getShort("TYPE") == DatabaseMetaData.tableIndexStatistic ) {
continue;
}
final Identifier indexIdentifier = DatabaseIdentifier.toIdentifier(uniqueKeyResult.getString("INDEX_NAME"));
IndexInformationImpl.Builder builder = builders.get( indexIdentifier );
if ( builder == null ) {
builder = IndexInformationImpl.builder( indexIdentifier ).setUnique(true);
builders.put( indexIdentifier, builder );
}
}
} finally {
uniqueKeyResult.close();
}
ResultSet resultSet = extractionContext.getJdbcDatabaseMetaData().getIndexInfo( ResultSet resultSet = extractionContext.getJdbcDatabaseMetaData().getIndexInfo(
catalogFilter, catalogFilter,
schemaFilter, schemaFilter,

2
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/spi/IndexInformation.java

@ -30,4 +30,6 @@ public interface IndexInformation {
* @return The columns * @return The columns
*/ */
public List<ColumnInformation> getIndexedColumns(); public List<ColumnInformation> getIndexedColumns();
boolean isUnique();
} }

104
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java

@ -6,12 +6,6 @@
*/ */
package com.fr.third.org.hibernate.tool.schema.internal; package com.fr.third.org.hibernate.tool.schema.internal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import com.fr.third.org.hibernate.boot.Metadata; import com.fr.third.org.hibernate.boot.Metadata;
import com.fr.third.org.hibernate.boot.model.naming.Identifier; import com.fr.third.org.hibernate.boot.model.naming.Identifier;
import com.fr.third.org.hibernate.boot.model.relational.AuxiliaryDatabaseObject; import com.fr.third.org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
@ -26,17 +20,21 @@ import com.fr.third.org.hibernate.engine.config.spi.StandardConverters;
import com.fr.third.org.hibernate.engine.jdbc.internal.FormatStyle; import com.fr.third.org.hibernate.engine.jdbc.internal.FormatStyle;
import com.fr.third.org.hibernate.engine.jdbc.internal.Formatter; import com.fr.third.org.hibernate.engine.jdbc.internal.Formatter;
import com.fr.third.org.hibernate.internal.util.StringHelper; import com.fr.third.org.hibernate.internal.util.StringHelper;
import com.fr.third.org.hibernate.mapping.Column;
import com.fr.third.org.hibernate.mapping.Constraint; import com.fr.third.org.hibernate.mapping.Constraint;
import com.fr.third.org.hibernate.mapping.ForeignKey; import com.fr.third.org.hibernate.mapping.ForeignKey;
import com.fr.third.org.hibernate.mapping.Index; import com.fr.third.org.hibernate.mapping.Index;
import com.fr.third.org.hibernate.mapping.PrimaryKey;
import com.fr.third.org.hibernate.mapping.Table; import com.fr.third.org.hibernate.mapping.Table;
import com.fr.third.org.hibernate.mapping.UniqueKey; import com.fr.third.org.hibernate.mapping.UniqueKey;
import com.fr.third.org.hibernate.resource.transaction.spi.DdlTransactionIsolator; import com.fr.third.org.hibernate.resource.transaction.spi.DdlTransactionIsolator;
import com.fr.third.org.hibernate.tool.hbm2ddl.UniqueConstraintSchemaUpdateStrategy; import com.fr.third.org.hibernate.tool.hbm2ddl.UniqueConstraintSchemaUpdateStrategy;
import com.fr.third.org.hibernate.tool.schema.extract.spi.ColumnInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.DatabaseInformation; import com.fr.third.org.hibernate.tool.schema.extract.spi.DatabaseInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.ForeignKeyInformation; import com.fr.third.org.hibernate.tool.schema.extract.spi.ForeignKeyInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.IndexInformation; import com.fr.third.org.hibernate.tool.schema.extract.spi.IndexInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.NameSpaceTablesInformation; import com.fr.third.org.hibernate.tool.schema.extract.spi.NameSpaceTablesInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.PrimaryKeyInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.SequenceInformation; import com.fr.third.org.hibernate.tool.schema.extract.spi.SequenceInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.TableInformation; import com.fr.third.org.hibernate.tool.schema.extract.spi.TableInformation;
import com.fr.third.org.hibernate.tool.schema.internal.exec.GenerationTarget; import com.fr.third.org.hibernate.tool.schema.internal.exec.GenerationTarget;
@ -48,9 +46,15 @@ import com.fr.third.org.hibernate.tool.schema.spi.SchemaFilter;
import com.fr.third.org.hibernate.tool.schema.spi.SchemaManagementException; import com.fr.third.org.hibernate.tool.schema.spi.SchemaManagementException;
import com.fr.third.org.hibernate.tool.schema.spi.SchemaMigrator; import com.fr.third.org.hibernate.tool.schema.spi.SchemaMigrator;
import com.fr.third.org.hibernate.tool.schema.spi.TargetDescriptor; import com.fr.third.org.hibernate.tool.schema.spi.TargetDescriptor;
import com.fr.third.org.jboss.logging.Logger; import com.fr.third.org.jboss.logging.Logger;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.fr.third.org.hibernate.cfg.AvailableSettings.UNIQUE_CONSTRAINT_SCHEMA_UPDATE_STRATEGY; import static com.fr.third.org.hibernate.cfg.AvailableSettings.UNIQUE_CONSTRAINT_SCHEMA_UPDATE_STRATEGY;
/** /**
@ -355,6 +359,29 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
if ( uniqueConstraintStrategy != UniqueConstraintSchemaUpdateStrategy.SKIP ) { if ( uniqueConstraintStrategy != UniqueConstraintSchemaUpdateStrategy.SKIP ) {
final Exporter<Constraint> exporter = dialect.getUniqueKeyExporter(); final Exporter<Constraint> exporter = dialect.getUniqueKeyExporter();
Set<Identifier> identifiers = getUniqueKeyIdentifiers(table);
if (tableInfo != null) {
for (IndexInformation indexInfo : tableInfo.getIndexes()) {
if (!indexInfo.isUnique() || indexInfo.getIndexIdentifier().equals(tableInfo.getPrimaryKey().getPrimaryKeyIdentifier())) {
continue;
}
//如果旧的唯一键已经不存在, 则删除
if (!identifiers.contains(indexInfo.getIndexIdentifier())) {
log.warn("delete unique key not existed in entity: " + indexInfo.getIndexIdentifier().getText());
UniqueKey old = new UniqueKey();
old.setTable(table);
old.setName(indexInfo.getIndexIdentifier().getText());
applySqlStrings(
true,
exporter.getSqlDropStrings(old, metadata),
formatter,
options,
targets
);
}
}
}
final Iterator ukItr = table.getUniqueKeyIterator(); final Iterator ukItr = table.getUniqueKeyIterator();
while ( ukItr.hasNext() ) { while ( ukItr.hasNext() ) {
final UniqueKey uniqueKey = (UniqueKey) ukItr.next(); final UniqueKey uniqueKey = (UniqueKey) ukItr.next();
@ -388,6 +415,18 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
} }
} }
private Set<Identifier> getUniqueKeyIdentifiers(Table table) {
Set<Identifier> identifiers = new HashSet<>();
Iterator<UniqueKey> uniqueKeys = table.getUniqueKeyIterator();
while (uniqueKeys.hasNext()) {
UniqueKey uniqueKey = uniqueKeys.next();
if (StringHelper.isNotEmpty(uniqueKey.getName())) {
identifiers.add(Identifier.toIdentifier(uniqueKey.getName()));
}
}
return identifiers;
}
private UniqueConstraintSchemaUpdateStrategy determineUniqueConstraintSchemaUpdateStrategy(Metadata metadata) { private UniqueConstraintSchemaUpdateStrategy determineUniqueConstraintSchemaUpdateStrategy(Metadata metadata) {
final ConfigurationService cfgService = ((MetadataImplementor) metadata).getMetadataBuildingOptions() final ConfigurationService cfgService = ((MetadataImplementor) metadata).getMetadataBuildingOptions()
.getServiceRegistry() .getServiceRegistry()
@ -446,6 +485,57 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
return tableInformation.getForeignKey( Identifier.toIdentifier( foreignKey.getName() ) ); return tableInformation.getForeignKey( Identifier.toIdentifier( foreignKey.getName() ) );
} }
protected void applyPrimaryKey(
Table table,
TableInformation tableInfo,
Dialect dialect,
Metadata metadata,
Formatter formatter,
ExecutionOptions options,
GenerationTarget... targets) {
try {
PrimaryKey primaryKey = table.getPrimaryKey();
if (primaryKey == null) {
return;
}
Exporter<PrimaryKey> exporter = new StandardPrimaryKeyExporter(dialect);
PrimaryKeyInformation existedPrimaryKeyInfo = tableInfo.getPrimaryKey();
if (existedPrimaryKeyInfo == null) {
applySqlStrings(true, exporter.getSqlCreateStrings(primaryKey, metadata), formatter, options, targets);
} else if (!columnEquals(table.getPrimaryKey().getColumns(), existedPrimaryKeyInfo.getColumns())) {
//主键列不匹配, 先删再增
PrimaryKey deletedKey = copyPrimaryKey(tableInfo.getPrimaryKey().getPrimaryKeyIdentifier().getText(), table);
applySqlStrings(true, exporter.getSqlDropStrings(deletedKey, metadata), formatter, options, targets);
applySqlStrings(true, exporter.getSqlCreateStrings(primaryKey, metadata), formatter, options, targets);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
private PrimaryKey copyPrimaryKey(String newName, Table table) {
PrimaryKey copy = new PrimaryKey(table);
copy.setName(newName);
return copy;
}
private boolean columnEquals(List<Column> columns, Iterable<ColumnInformation> iterator) {
int count = 0;
Set<String> names = new HashSet<String>();
for (Column column: columns) {
names.add(column.getName().toLowerCase());
}
for (ColumnInformation columnInformation : iterator) {
String name = columnInformation.getColumnIdentifier().getText();
if (!names.contains(name.toLowerCase())) {
return false;
}
count++;
}
return count == columns.size();
}
protected void checkExportIdentifier(Exportable exportable, Set<String> exportIdentifiers) { protected void checkExportIdentifier(Exportable exportable, Set<String> exportIdentifiers) {
final String exportIdentifier = exportable.getExportIdentifier(); final String exportIdentifier = exportable.getExportIdentifier();
if ( exportIdentifiers.contains( exportIdentifier ) ) { if ( exportIdentifiers.contains( exportIdentifier ) ) {

3
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java

@ -83,6 +83,9 @@ public class GroupedSchemaMigratorImpl extends AbstractSchemaMigrator {
if ( tableInformation == null || ( tableInformation != null && tableInformation.isPhysicalTable() ) ) { if ( tableInformation == null || ( tableInformation != null && tableInformation.isPhysicalTable() ) ) {
applyIndexes( table, tableInformation, dialect, metadata, formatter, options, targets ); applyIndexes( table, tableInformation, dialect, metadata, formatter, options, targets );
applyUniqueKeys( table, tableInformation, dialect, metadata, formatter, options, targets ); applyUniqueKeys( table, tableInformation, dialect, metadata, formatter, options, targets );
if (tableInformation != null) {
applyPrimaryKey(table, tableInformation, dialect, metadata, formatter, options, targets);
}
} }
} }
} }

3
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java

@ -83,6 +83,9 @@ public class IndividuallySchemaMigratorImpl extends AbstractSchemaMigrator {
if ( tableInformation == null || ( tableInformation != null && tableInformation.isPhysicalTable() ) ) { if ( tableInformation == null || ( tableInformation != null && tableInformation.isPhysicalTable() ) ) {
applyIndexes( table, tableInformation, dialect, metadata, formatter, options, targets ); applyIndexes( table, tableInformation, dialect, metadata, formatter, options, targets );
applyUniqueKeys( table, tableInformation, dialect, metadata, formatter, options, targets ); applyUniqueKeys( table, tableInformation, dialect, metadata, formatter, options, targets );
if (tableInformation != null) {
applyPrimaryKey(table, tableInformation, dialect, metadata, formatter, options, targets);
}
} }
} }
} }

63
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/StandardPrimaryKeyExporter.java

@ -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() };
}
}

4
fine-spring/src/main/java/com/fr/third/springframework/web/multipart/MultipartFile.java

@ -50,7 +50,7 @@ public interface MultipartFile extends InputStreamSource {
* but it typically will not with any other than Opera. * but it typically will not with any other than Opera.
* @return the original filename, or the empty String if no file has been chosen * @return the original filename, or the empty String if no file has been chosen
* in the multipart form, or {@code null} if not defined or not available * in the multipart form, or {@code null} if not defined or not available
* @see org.apache.commons.fileupload.FileItem#getName() * @see com.fr.third.org.apache.commons.fileupload.FileItem#getName()
* @see com.fr.third.springframework.web.multipart.commons.CommonsMultipartFile#setPreserveFilename * @see com.fr.third.springframework.web.multipart.commons.CommonsMultipartFile#setPreserveFilename
*/ */
String getOriginalFilename(); String getOriginalFilename();
@ -107,7 +107,7 @@ public interface MultipartFile extends InputStreamSource {
* @throws IOException in case of reading or writing errors * @throws IOException in case of reading or writing errors
* @throws IllegalStateException if the file has already been moved * @throws IllegalStateException if the file has already been moved
* in the filesystem and is not available anymore for another transfer * in the filesystem and is not available anymore for another transfer
* @see org.apache.commons.fileupload.FileItem#write(File) * @see com.fr.third.org.apache.commons.fileupload.FileItem#write(File)
* @see javax.servlet.http.Part#write(String) * @see javax.servlet.http.Part#write(String)
*/ */
void transferTo(File dest) throws IOException, IllegalStateException; void transferTo(File dest) throws IOException, IllegalStateException;

24
fine-spring/src/main/java/com/fr/third/springframework/web/multipart/commons/CommonsFileUploadSupport.java

@ -23,10 +23,10 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.fileupload.FileItem; import com.fr.third.org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory; import com.fr.third.org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUpload; import com.fr.third.org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import com.fr.third.org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -84,7 +84,7 @@ public abstract class CommonsFileUploadSupport {
/** /**
* Return the underlying {@code org.apache.commons.fileupload.disk.DiskFileItemFactory} * Return the underlying {@code com.fr.third.org.apache.commons.fileupload.disk.DiskFileItemFactory}
* instance. There is hardly any need to access this. * instance. There is hardly any need to access this.
* @return the underlying DiskFileItemFactory instance * @return the underlying DiskFileItemFactory instance
*/ */
@ -93,7 +93,7 @@ public abstract class CommonsFileUploadSupport {
} }
/** /**
* Return the underlying {@code org.apache.commons.fileupload.FileUpload} * Return the underlying {@code com.fr.third.org.apache.commons.fileupload.FileUpload}
* instance. There is hardly any need to access this. * instance. There is hardly any need to access this.
* @return the underlying FileUpload instance * @return the underlying FileUpload instance
*/ */
@ -105,7 +105,7 @@ public abstract class CommonsFileUploadSupport {
* Set the maximum allowed size (in bytes) before an upload gets rejected. * Set the maximum allowed size (in bytes) before an upload gets rejected.
* -1 indicates no limit (the default). * -1 indicates no limit (the default).
* @param maxUploadSize the maximum upload size allowed * @param maxUploadSize the maximum upload size allowed
* @see org.apache.commons.fileupload.FileUploadBase#setSizeMax * @see com.fr.third.org.apache.commons.fileupload.FileUploadBase#setSizeMax
*/ */
public void setMaxUploadSize(long maxUploadSize) { public void setMaxUploadSize(long maxUploadSize) {
this.fileUpload.setSizeMax(maxUploadSize); this.fileUpload.setSizeMax(maxUploadSize);
@ -116,7 +116,7 @@ public abstract class CommonsFileUploadSupport {
* an upload gets rejected. -1 indicates no limit (the default). * an upload gets rejected. -1 indicates no limit (the default).
* @param maxUploadSizePerFile the maximum upload size per file * @param maxUploadSizePerFile the maximum upload size per file
* @since 4.2 * @since 4.2
* @see org.apache.commons.fileupload.FileUploadBase#setFileSizeMax * @see com.fr.third.org.apache.commons.fileupload.FileUploadBase#setFileSizeMax
*/ */
public void setMaxUploadSizePerFile(long maxUploadSizePerFile) { public void setMaxUploadSizePerFile(long maxUploadSizePerFile) {
this.fileUpload.setFileSizeMax(maxUploadSizePerFile); this.fileUpload.setFileSizeMax(maxUploadSizePerFile);
@ -127,7 +127,7 @@ public abstract class CommonsFileUploadSupport {
* Uploaded files will still be received past this amount, but they will not be * Uploaded files will still be received past this amount, but they will not be
* stored in memory. Default is 10240, according to Commons FileUpload. * stored in memory. Default is 10240, according to Commons FileUpload.
* @param maxInMemorySize the maximum in memory size allowed * @param maxInMemorySize the maximum in memory size allowed
* @see org.apache.commons.fileupload.disk.DiskFileItemFactory#setSizeThreshold * @see com.fr.third.org.apache.commons.fileupload.disk.DiskFileItemFactory#setSizeThreshold
*/ */
public void setMaxInMemorySize(int maxInMemorySize) { public void setMaxInMemorySize(int maxInMemorySize) {
this.fileItemFactory.setSizeThreshold(maxInMemorySize); this.fileItemFactory.setSizeThreshold(maxInMemorySize);
@ -145,7 +145,7 @@ public abstract class CommonsFileUploadSupport {
* @see javax.servlet.ServletRequest#getCharacterEncoding * @see javax.servlet.ServletRequest#getCharacterEncoding
* @see javax.servlet.ServletRequest#setCharacterEncoding * @see javax.servlet.ServletRequest#setCharacterEncoding
* @see WebUtils#DEFAULT_CHARACTER_ENCODING * @see WebUtils#DEFAULT_CHARACTER_ENCODING
* @see org.apache.commons.fileupload.FileUploadBase#setHeaderEncoding * @see com.fr.third.org.apache.commons.fileupload.FileUploadBase#setHeaderEncoding
*/ */
public void setDefaultEncoding(String defaultEncoding) { public void setDefaultEncoding(String defaultEncoding) {
this.fileUpload.setHeaderEncoding(defaultEncoding); this.fileUpload.setHeaderEncoding(defaultEncoding);
@ -248,7 +248,7 @@ public abstract class CommonsFileUploadSupport {
* @param fileItems the Commons FileIterms to parse * @param fileItems the Commons FileIterms to parse
* @param encoding the encoding to use for form fields * @param encoding the encoding to use for form fields
* @return the Spring MultipartParsingResult * @return the Spring MultipartParsingResult
* @see CommonsMultipartFile#CommonsMultipartFile(org.apache.commons.fileupload.FileItem) * @see CommonsMultipartFile#CommonsMultipartFile(com.fr.third.org.apache.commons.fileupload.FileItem)
*/ */
protected MultipartParsingResult parseFileItems(List<FileItem> fileItems, String encoding) { protected MultipartParsingResult parseFileItems(List<FileItem> fileItems, String encoding) {
MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>(); MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>();
@ -320,7 +320,7 @@ public abstract class CommonsFileUploadSupport {
* potentially holding temporary data on disk. * potentially holding temporary data on disk.
* <p>Deletes the underlying Commons FileItem instances. * <p>Deletes the underlying Commons FileItem instances.
* @param multipartFiles Collection of MultipartFile instances * @param multipartFiles Collection of MultipartFile instances
* @see org.apache.commons.fileupload.FileItem#delete() * @see com.fr.third.org.apache.commons.fileupload.FileItem#delete()
*/ */
protected void cleanupFileItems(MultiValueMap<String, MultipartFile> multipartFiles) { protected void cleanupFileItems(MultiValueMap<String, MultipartFile> multipartFiles) {
for (List<MultipartFile> files : multipartFiles.values()) { for (List<MultipartFile> files : multipartFiles.values()) {

8
fine-spring/src/main/java/com/fr/third/springframework/web/multipart/commons/CommonsMultipartFile.java

@ -21,9 +21,9 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import org.apache.commons.fileupload.FileItem; import com.fr.third.org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException; import com.fr.third.org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItem; import com.fr.third.org.apache.commons.fileupload.disk.DiskFileItem;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -61,7 +61,7 @@ public class CommonsMultipartFile implements MultipartFile, Serializable {
/** /**
* Return the underlying {@code org.apache.commons.fileupload.FileItem} * Return the underlying {@code com.fr.third.org.apache.commons.fileupload.FileItem}
* instance. There is hardly any need to access this. * instance. There is hardly any need to access this.
*/ */
public final FileItem getFileItem() { public final FileItem getFileItem() {

18
fine-spring/src/main/java/com/fr/third/springframework/web/multipart/commons/CommonsMultipartResolver.java

@ -20,12 +20,12 @@ import java.util.List;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.fileupload.FileItem; import com.fr.third.org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory; import com.fr.third.org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUpload; import com.fr.third.org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.FileUploadBase; import com.fr.third.org.apache.commons.fileupload.FileUploadBase;
import org.apache.commons.fileupload.FileUploadException; import com.fr.third.org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.servlet.ServletFileUpload; import com.fr.third.org.apache.commons.fileupload.servlet.ServletFileUpload;
import com.fr.third.springframework.util.Assert; import com.fr.third.springframework.util.Assert;
import com.fr.third.springframework.web.context.ServletContextAware; import com.fr.third.springframework.web.context.ServletContextAware;
@ -57,8 +57,8 @@ import com.fr.third.springframework.web.util.WebUtils;
* @see #CommonsMultipartResolver(ServletContext) * @see #CommonsMultipartResolver(ServletContext)
* @see #setResolveLazily * @see #setResolveLazily
* @see com.fr.third.springframework.web.portlet.multipart.CommonsPortletMultipartResolver * @see com.fr.third.springframework.web.portlet.multipart.CommonsPortletMultipartResolver
* @see org.apache.commons.fileupload.servlet.ServletFileUpload * @see com.fr.third.org.apache.commons.fileupload.servlet.ServletFileUpload
* @see org.apache.commons.fileupload.disk.DiskFileItemFactory * @see com.fr.third.org.apache.commons.fileupload.disk.DiskFileItemFactory
*/ */
public class CommonsMultipartResolver extends CommonsFileUploadSupport public class CommonsMultipartResolver extends CommonsFileUploadSupport
implements MultipartResolver, ServletContextAware { implements MultipartResolver, ServletContextAware {
@ -102,7 +102,7 @@ public class CommonsMultipartResolver extends CommonsFileUploadSupport
} }
/** /**
* Initialize the underlying {@code org.apache.commons.fileupload.servlet.ServletFileUpload} * Initialize the underlying {@code com.fr.third.org.apache.commons.fileupload.servlet.ServletFileUpload}
* instance. Can be overridden to use a custom subclass, e.g. for testing purposes. * instance. Can be overridden to use a custom subclass, e.g. for testing purposes.
* @param fileItemFactory the Commons FileItemFactory to use * @param fileItemFactory the Commons FileItemFactory to use
* @return the new ServletFileUpload instance * @return the new ServletFileUpload instance

Loading…
Cancel
Save