Browse Source

Merge pull request #8515 in CORE/base-third from bugfix/11.0 to feature/x

* commit 'e459b6953806de00ce9338c7b272d572fb73ed43':
  REPORT-90336【来源内测BUG】平台左侧目录搜索很慢
feature/x
superman 2 years ago
parent
commit
db74461cdb
  1. 12
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java
  2. 9
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/boot/internal/SessionFactoryOptionsImpl.java
  3. 2
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/boot/internal/SessionFactoryOptionsState.java
  4. 5
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryOptions.java
  5. 2
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/boot/spi/SessionFactoryOptions.java
  6. 11
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/cfg/AvailableSettings.java
  7. 2
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java
  8. 2
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/hql/internal/ast/tree/JavaConstantNode.java
  9. 2
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/hql/internal/ast/util/LiteralProcessor.java
  10. 2
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/hql/internal/classic/WhereParser.java
  11. 12
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/internal/util/ReflectHelper.java

12
fine-hibernate/src/main/java/com/fr/third/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java

@ -483,6 +483,7 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
private Map querySubstitutions; private Map querySubstitutions;
private boolean strictJpaQueryLanguageCompliance; private boolean strictJpaQueryLanguageCompliance;
private boolean namedQueryStartupCheckingEnabled; private boolean namedQueryStartupCheckingEnabled;
private boolean conventionalJavaConstants;
private final boolean procedureParameterNullPassingEnabled; private final boolean procedureParameterNullPassingEnabled;
private final boolean collectionJoinSubqueryRewriteEnabled; private final boolean collectionJoinSubqueryRewriteEnabled;
@ -600,6 +601,8 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
this.querySubstitutions = ConfigurationHelper.toMap( QUERY_SUBSTITUTIONS, " ,=;:\n\t\r\f", configurationSettings ); this.querySubstitutions = ConfigurationHelper.toMap( QUERY_SUBSTITUTIONS, " ,=;:\n\t\r\f", configurationSettings );
this.strictJpaQueryLanguageCompliance = cfgService.getSetting( JPAQL_STRICT_COMPLIANCE, BOOLEAN, false ); this.strictJpaQueryLanguageCompliance = cfgService.getSetting( JPAQL_STRICT_COMPLIANCE, BOOLEAN, false );
this.namedQueryStartupCheckingEnabled = cfgService.getSetting( QUERY_STARTUP_CHECKING, BOOLEAN, true ); this.namedQueryStartupCheckingEnabled = cfgService.getSetting( QUERY_STARTUP_CHECKING, BOOLEAN, true );
this.conventionalJavaConstants = cfgService.getSetting(
CONVENTIONAL_JAVA_CONSTANTS, BOOLEAN, true );
this.procedureParameterNullPassingEnabled = cfgService.getSetting( PROCEDURE_NULL_PARAM_PASSING, BOOLEAN, false ); this.procedureParameterNullPassingEnabled = cfgService.getSetting( PROCEDURE_NULL_PARAM_PASSING, BOOLEAN, false );
this.collectionJoinSubqueryRewriteEnabled = cfgService.getSetting( COLLECTION_JOIN_SUBQUERY, BOOLEAN, true ); this.collectionJoinSubqueryRewriteEnabled = cfgService.getSetting( COLLECTION_JOIN_SUBQUERY, BOOLEAN, true );
@ -851,6 +854,11 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
return namedQueryStartupCheckingEnabled; return namedQueryStartupCheckingEnabled;
} }
@Override
public boolean isConventionalJavaConstants() {
return conventionalJavaConstants;
}
@Override @Override
public boolean isProcedureParameterNullPassingEnabled() { public boolean isProcedureParameterNullPassingEnabled() {
return procedureParameterNullPassingEnabled; return procedureParameterNullPassingEnabled;
@ -1132,6 +1140,10 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
return options.isNamedQueryStartupCheckingEnabled(); return options.isNamedQueryStartupCheckingEnabled();
} }
@Override
public boolean isConventionalJavaConstants() {
return options.isConventionalJavaConstants();
}
@Override @Override
public boolean isProcedureParameterNullPassingEnabled() { public boolean isProcedureParameterNullPassingEnabled() {
return options.isProcedureParameterNullPassingEnabled(); return options.isProcedureParameterNullPassingEnabled();

9
fine-hibernate/src/main/java/com/fr/third/org/hibernate/boot/internal/SessionFactoryOptionsImpl.java

@ -88,6 +88,9 @@ public class SessionFactoryOptionsImpl implements SessionFactoryOptions {
private final Map querySubstitutions; private final Map querySubstitutions;
private final boolean strictJpaQueryLanguageCompliance; private final boolean strictJpaQueryLanguageCompliance;
private final boolean namedQueryStartupCheckingEnabled; private final boolean namedQueryStartupCheckingEnabled;
private final boolean conventionalJavaConstants;
private final boolean procedureParameterNullPassingEnabled; private final boolean procedureParameterNullPassingEnabled;
private final boolean collectionJoinSubqueryRewriteEnabled; private final boolean collectionJoinSubqueryRewriteEnabled;
@ -160,6 +163,7 @@ public class SessionFactoryOptionsImpl implements SessionFactoryOptions {
this.querySubstitutions = state.getQuerySubstitutions(); this.querySubstitutions = state.getQuerySubstitutions();
this.strictJpaQueryLanguageCompliance = state.isStrictJpaQueryLanguageCompliance(); this.strictJpaQueryLanguageCompliance = state.isStrictJpaQueryLanguageCompliance();
this.namedQueryStartupCheckingEnabled = state.isNamedQueryStartupCheckingEnabled(); this.namedQueryStartupCheckingEnabled = state.isNamedQueryStartupCheckingEnabled();
this.conventionalJavaConstants = state.isConventionalJavaConstants();
this.procedureParameterNullPassingEnabled = state.isProcedureParameterNullPassingEnabled(); this.procedureParameterNullPassingEnabled = state.isProcedureParameterNullPassingEnabled();
this.collectionJoinSubqueryRewriteEnabled = state.isCollectionJoinSubqueryRewriteEnabled(); this.collectionJoinSubqueryRewriteEnabled = state.isCollectionJoinSubqueryRewriteEnabled();
@ -339,6 +343,11 @@ public class SessionFactoryOptionsImpl implements SessionFactoryOptions {
return namedQueryStartupCheckingEnabled; return namedQueryStartupCheckingEnabled;
} }
@Override
public boolean isConventionalJavaConstants() {
return conventionalJavaConstants;
}
@Override @Override
public boolean isProcedureParameterNullPassingEnabled() { public boolean isProcedureParameterNullPassingEnabled() {
return procedureParameterNullPassingEnabled; return procedureParameterNullPassingEnabled;

2
fine-hibernate/src/main/java/com/fr/third/org/hibernate/boot/internal/SessionFactoryOptionsState.java

@ -98,6 +98,8 @@ public interface SessionFactoryOptionsState {
boolean isNamedQueryStartupCheckingEnabled(); boolean isNamedQueryStartupCheckingEnabled();
boolean isConventionalJavaConstants();
boolean isProcedureParameterNullPassingEnabled(); boolean isProcedureParameterNullPassingEnabled();
boolean isCollectionJoinSubqueryRewriteEnabled(); boolean isCollectionJoinSubqueryRewriteEnabled();

5
fine-hibernate/src/main/java/com/fr/third/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryOptions.java

@ -198,6 +198,11 @@ public abstract class AbstractDelegatingSessionFactoryOptions implements Session
return delegate.isNamedQueryStartupCheckingEnabled(); return delegate.isNamedQueryStartupCheckingEnabled();
} }
@Override
public boolean isConventionalJavaConstants() {
return delegate.isConventionalJavaConstants();
}
@Override @Override
public boolean isProcedureParameterNullPassingEnabled() { public boolean isProcedureParameterNullPassingEnabled() {
return delegate.isProcedureParameterNullPassingEnabled(); return delegate.isProcedureParameterNullPassingEnabled();

2
fine-hibernate/src/main/java/com/fr/third/org/hibernate/boot/spi/SessionFactoryOptions.java

@ -122,6 +122,8 @@ public interface SessionFactoryOptions {
boolean isNamedQueryStartupCheckingEnabled(); boolean isNamedQueryStartupCheckingEnabled();
boolean isConventionalJavaConstants();
boolean isSecondLevelCacheEnabled(); boolean isSecondLevelCacheEnabled();
boolean isQueryCacheEnabled(); boolean isQueryCacheEnabled();

11
fine-hibernate/src/main/java/com/fr/third/org/hibernate/cfg/AvailableSettings.java

@ -564,6 +564,17 @@ public interface AvailableSettings {
*/ */
String QUERY_STARTUP_CHECKING = "hibernate.query.startup_check"; String QUERY_STARTUP_CHECKING = "hibernate.query.startup_check";
/**
* Setting which indicates whether or not Java constant follow the Java Naming conventions.
* <p/>
* Default is {@code true}. Existing applications may want to disable this (set it {@code false}) if non-conventional Java constants are used.
* However, there is a significant performance overhead for using non-conventional Java constants since Hibernate cannot determine if aliases
* should be treated as Java constants or not.
*
* @since 5.2
*/
String CONVENTIONAL_JAVA_CONSTANTS = "hibernate.query.conventional_java_constants";
/** /**
* The {@link com.fr.third.org.hibernate.exception.spi.SQLExceptionConverter} to use for converting SQLExceptions * The {@link com.fr.third.org.hibernate.exception.spi.SQLExceptionConverter} to use for converting SQLExceptions
* to Hibernate's JDBCException hierarchy. The default is to use the configured * to Hibernate's JDBCException hierarchy. The default is to use the configured

2
fine-hibernate/src/main/java/com/fr/third/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java

@ -612,7 +612,7 @@ public class QueryTranslatorImpl implements FilterTranslator {
} }
private void handleDotStructure(AST dotStructureRoot) { private void handleDotStructure(AST dotStructureRoot) {
final String expression = ASTUtil.getPathText( dotStructureRoot ); final String expression = ASTUtil.getPathText( dotStructureRoot );
final Object constant = ReflectHelper.getConstantValue( expression, factory.getServiceRegistry().getService( ClassLoaderService.class ) ); final Object constant = ReflectHelper.getConstantValue( expression, factory );
if ( constant != null ) { if ( constant != null ) {
dotStructureRoot.setFirstChild( null ); dotStructureRoot.setFirstChild( null );
dotStructureRoot.setType( HqlTokenTypes.JAVA_CONSTANT ); dotStructureRoot.setType( HqlTokenTypes.JAVA_CONSTANT );

2
fine-hibernate/src/main/java/com/fr/third/org/hibernate/hql/internal/ast/tree/JavaConstantNode.java

@ -39,7 +39,7 @@ public class JavaConstantNode extends Node implements ExpectedTypeAwareNode, Ses
// this method to get called twice. The first time with an empty string // this method to get called twice. The first time with an empty string
if ( StringHelper.isNotEmpty( s ) ) { if ( StringHelper.isNotEmpty( s ) ) {
constantExpression = s; constantExpression = s;
constantValue = ReflectHelper.getConstantValue( s, factory.getServiceRegistry().getService( ClassLoaderService.class ) ); constantValue = ReflectHelper.getConstantValue( s, factory );
heuristicType = factory.getTypeResolver().heuristicType( constantValue.getClass().getName() ); heuristicType = factory.getTypeResolver().heuristicType( constantValue.getClass().getName() );
super.setText( s ); super.setText( s );
} }

2
fine-hibernate/src/main/java/com/fr/third/org/hibernate/hql/internal/ast/util/LiteralProcessor.java

@ -107,7 +107,7 @@ public class LiteralProcessor implements HqlSqlTokenTypes {
setSQLValue( node, text, discrim ); setSQLValue( node, text, discrim );
} }
else { else {
Object value = ReflectHelper.getConstantValue( text, walker.getSessionFactoryHelper().getFactory().getServiceRegistry().getService( ClassLoaderService.class ) ); Object value = ReflectHelper.getConstantValue( text, walker.getSessionFactoryHelper().getFactory() );
if ( value == null ) { if ( value == null ) {
throw new InvalidPathException( "Invalid path: '" + text + "'" ); throw new InvalidPathException( "Invalid path: '" + text + "'" );
} }

2
fine-hibernate/src/main/java/com/fr/third/org/hibernate/hql/internal/classic/WhereParser.java

@ -419,7 +419,7 @@ public class WhereParser implements Parser {
Object constant; Object constant;
if ( if (
token.indexOf( '.' ) > -1 && token.indexOf( '.' ) > -1 &&
( constant = ReflectHelper.getConstantValue( token, q.getFactory().getServiceRegistry().getService( ClassLoaderService.class ) ) ) != null ( constant = ReflectHelper.getConstantValue( token, q.getFactory() ) ) != null
) { ) {
Type type; Type type;
try { try {

12
fine-hibernate/src/main/java/com/fr/third/org/hibernate/internal/util/ReflectHelper.java

@ -13,12 +13,14 @@ import java.lang.reflect.Member;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Pattern;
import com.fr.third.org.hibernate.AssertionFailure; import com.fr.third.org.hibernate.AssertionFailure;
import com.fr.third.org.hibernate.MappingException; import com.fr.third.org.hibernate.MappingException;
import com.fr.third.org.hibernate.PropertyNotFoundException; import com.fr.third.org.hibernate.PropertyNotFoundException;
import com.fr.third.org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import com.fr.third.org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import com.fr.third.org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import com.fr.third.org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import com.fr.third.org.hibernate.engine.spi.SessionFactoryImplementor;
import com.fr.third.org.hibernate.property.access.internal.PropertyAccessStrategyMixedImpl; import com.fr.third.org.hibernate.property.access.internal.PropertyAccessStrategyMixedImpl;
import com.fr.third.org.hibernate.property.access.spi.Getter; import com.fr.third.org.hibernate.property.access.spi.Getter;
import com.fr.third.org.hibernate.type.PrimitiveType; import com.fr.third.org.hibernate.type.PrimitiveType;
@ -32,6 +34,8 @@ import com.fr.third.org.hibernate.type.Type;
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final class ReflectHelper { public final class ReflectHelper {
private static final Pattern JAVA_CONSTANT_PATTERN = Pattern.compile(
"[a-z\\d]+\\.([A-Z]+[a-z\\d]+)+\\$?([A-Z]{1}[a-z\\d]+)*\\.[A-Z_\\$]+", Pattern.UNICODE_CHARACTER_CLASS);
public static final Class[] NO_PARAM_SIGNATURE = new Class[0]; public static final Class[] NO_PARAM_SIGNATURE = new Class[0];
public static final Object[] NO_PARAMS = new Object[0]; public static final Object[] NO_PARAMS = new Object[0];
@ -229,9 +233,15 @@ public final class ReflectHelper {
return PropertyAccessStrategyMixedImpl.INSTANCE.buildPropertyAccess( clazz, name ).getGetter(); return PropertyAccessStrategyMixedImpl.INSTANCE.buildPropertyAccess( clazz, name ).getGetter();
} }
public static Object getConstantValue(String name, ClassLoaderService classLoaderService) { public static Object getConstantValue(String name, SessionFactoryImplementor factory) {
boolean conventionalJavaConstants = factory.getSessionFactoryOptions().isConventionalJavaConstants();
Class clazz; Class clazz;
try { try {
if ( conventionalJavaConstants &&
!JAVA_CONSTANT_PATTERN.matcher( name ).find() ) {
return null;
}
ClassLoaderService classLoaderService = factory.getServiceRegistry().getService( ClassLoaderService.class );
clazz = classLoaderService.classForName( StringHelper.qualifier( name ) ); clazz = classLoaderService.classForName( StringHelper.qualifier( name ) );
} }
catch ( Throwable t ) { catch ( Throwable t ) {

Loading…
Cancel
Save