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?
Conversation
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 + "]." + |
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.
- we don't need punctuation at the end of exception messages, that's quite nonstandard, and
- I have been gradually migrating to the use of single quotes for quoting the names of program elements, since square brackets have more visual weight than is needed for this purpose.
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
Thanks for your pull request! This pull request appears to follow the contribution rules. › This message was automatically generated. |
# change 1. remove punctuation at the end of exception messages 2. replace square brackets with single quotes
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 + "'" + |
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.
throw new SemanticException("Missing constructor or attributes for injection into type '" + type + "'" + | |
throw new SemanticException("Missing constructor or attributes for injection into type '" + type.getSimpleName() + "'" + |
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.
I think a type description like com.excemple.A
would be clearer than just
showing A
, especially if there are classes with duplicate names, and
would make it easier to find problematic classes more quickly.
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.
I'm not certain I agree, but anyway that's not what you have there. You are calling Class.toString()
, which does not just return the qualified name.
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.
I understand your concern, I've used Class.getName()
replace Class.toString()
.
# change 1. using Class.getName() replace Class.toString()
.map(InstantiationHelper.MismatchConstructorFieldPositionInfo::toString) | ||
.collect(Collectors.joining(",")); |
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.
You can use StringHelper.join()
for this.
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.
I have finished the modification
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 comment
The reason will be displayed to describe this comment to others. Learn more.
if (list != null && list.isEmpty() == false) { | |
if ( list != null && !list.isEmpty() ) { |
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.
I have finished the modification
throw new SemanticException("Unable to locate appropriate constructor on class '" + qualifiedName + "'. " + | ||
"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.
throw new SemanticException("Unable to locate appropriate constructor on class '" + qualifiedName + "'. " + | |
"Expected arguments are: " + dynamicInstantiation.argumentTypes() + conjecture, query); | |
throw new SemanticException( "Missing constructor for class '" + qualifiedName + "' with parameter types [" | |
+ 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.
I have finished the modification
|
||
String conjecture = ""; | ||
if (list != null && list.isEmpty() == false) { | ||
conjecture = " The presumed mismatch field position is: " + |
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.
conjecture = " The presumed mismatch field position is: " + | |
conjecture = "mismatch at position " + |
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.
I have finished the modification
throw new SemanticException("Missing constructor or attributes for injection into type '" + qualifiedName + "'" + | ||
"Expected arguments are: " + dynamicInstantiation.argumentTypes(), 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.
throw new SemanticException("Missing constructor or attributes for injection into type '" + qualifiedName + "'" + | |
"Expected arguments are: " + dynamicInstantiation.argumentTypes(), query); | |
throw new SemanticException( "Missing constructor or attributes for injection into class '" + qualifiedName + "'" + | |
" of selected types [" + dynamicInstantiation.argumentTypes() + "]", 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.
I have finished the modification
# change 1. modify code format 2. modify the format of exception information
# change 1. use StringHelper.join() instead of stream processing
Is there anything I would like to change about this branch? @gavinking |
I have provided an implementation for HH-17926, please check it out.
https://hibernate.atlassian.net/browse/HHH-17926