|
So in my mind there are 2 parts to this, even outside the question of enums:
-
How to recognize that a string in a query represents a constant, and how to consume that string into a typed representation of that constant
-
How to render a recognized constant when rendering the sql.
I think JavaConstantNode already does a good job as far as consuming the String representation into typed representation. The concept of recognizing a constant is actually done higher up in the translation code, and could certainly use some help; although again, in this case it does a good enough job (the enum constant reference is recognized as such).
JavaConstantNode, however, was falling down when trying to render these constants. That is really all the associated Pull Request attempted to address. The thing I did not like about the approach taken by the pull request is that is assumes (and never verifies) that "db type" of the AttributeConverter is a String (or that at the very least that the database will be able to perform an implicit conversion from a VARCHAR to the type actually indicated by the AttributeConverter. Also, it the fix as is would only ever work for enum references using an AttributeCnverter, not attributes of any other kind using an AttributeConverter. I went a little bit different of a direction in terms of handling this, that does in fact handle all cases where an AttributeConverter is used.
|