Skip to content
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

CriteriaQueryTranslator can throw a better exception when criteria is placed directly on component #3455

Open
tohidemyname opened this issue Nov 29, 2023 · 0 comments

Comments

@tohidemyname
Copy link

This bug was originally reported to hiberante:
https://hibernate.atlassian.net/browse/HHH-3646

The buggy code of hibernate is:

getPathInfo(String){
...
else if ( type.isComponentType() ) {
componentPath += '.';
}
}

The fixed code is as follows:
getPathInfo(String){
...
else if ( type.isComponentType() ) {
if (!tokens.hasMoreTokens()) {
throw new QueryException("Criteria objects cannot be created directly on components. Create a criteria on owning entity and use a dotted property to access component property: "+path);
} else {
componentPath += '.';
}
}
}

The commit is hibernate/hibernate-orm@90fdca9

In nhibernate, the latest code is still identical to the buggy code:

private ICriteriaInfoProvider GetPathInfo(string path, ICriteriaInfoProvider rootProvider){
...
else if (type.IsComponentType)
{
componentPath += '.';
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant