-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhance type-checked result effect during the call to createQuery() #8152
base: main
Are you sure you want to change the base?
Changes from 1 commit
71f1276
1f8af8c
0b8574b
3f36dff
d14dcdf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,6 +32,7 @@ | |||||
import java.util.Locale; | ||||||
import java.util.Map; | ||||||
import java.util.Set; | ||||||
import java.util.stream.Collectors; | ||||||
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; | ||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; | ||||||
|
@@ -214,6 +215,7 @@ | |||||
import org.hibernate.sql.ast.SqlAstNodeRenderingMode; | ||||||
import org.hibernate.sql.ast.tree.cte.CteMaterialization; | ||||||
import org.hibernate.sql.ast.tree.cte.CteSearchClauseKind; | ||||||
import org.hibernate.sql.results.graph.instantiation.internal.InstantiationHelper; | ||||||
import org.hibernate.type.BasicPluralType; | ||||||
import org.hibernate.type.BasicType; | ||||||
import org.hibernate.type.descriptor.java.JavaType; | ||||||
|
@@ -1498,12 +1500,24 @@ public SqmDynamicInstantiation<?> visitInstantiation(HqlParser.InstantiationCont | |||||
} | ||||||
|
||||||
if ( !dynamicInstantiation.checkInstantiation( creationContext.getTypeConfiguration() ) ) { | ||||||
final String typeName = dynamicInstantiation.getJavaType().getSimpleName(); | ||||||
final Class<?> type = dynamicInstantiation.getJavaType(); | ||||||
if ( dynamicInstantiation.isFullyAliased() ) { | ||||||
throw new SemanticException( "Missing constructor or attributes for injection into type '" + typeName + "'", query ); | ||||||
throw new SemanticException("Missing constructor or attributes for injection into type [" + type + "]." + | ||||||
"Expected arguments are: " + dynamicInstantiation.argumentTypes(), query); | ||||||
} | ||||||
else { | ||||||
throw new SemanticException( "Missing constructor for type '" + typeName + "'", query ); | ||||||
List<InstantiationHelper.MismatchConstructorFieldPositionInfo> list = dynamicInstantiation.findMismatchConstructorFieldPositions(creationContext.getTypeConfiguration()); | ||||||
|
||||||
String conjecture = ""; | ||||||
if (list != null && list.isEmpty() == false) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have finished the modification |
||||||
conjecture = " The presumed mismatch field position is: " + | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have finished the modification |
||||||
list.stream() | ||||||
.map(InstantiationHelper.MismatchConstructorFieldPositionInfo::toString) | ||||||
.collect(Collectors.joining(",")); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have finished the modification |
||||||
} | ||||||
|
||||||
throw new SemanticException("Unable to locate appropriate constructor on class [" + type + "]. " + | ||||||
"Expected arguments are: " + dynamicInstantiation.argumentTypes() + conjecture, query); | ||||||
} | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please back out this change and the other one like it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reminding me, I have finished the modification