PropertyMapping.toColumn(String, String) with Hibernate 6

Hi,

I was using ((PropertyMapping) entityPersister).toColumns(alias, property); on an entity persister in order to get the corresponding SQL for that property, correctly aliased (in particular it dealt correctly with both basic properties and @Formula properties).

In Hibernate 6, PropertyMapping is deprecated and that method got removed. There are many mentions about using AttributeMapping but there are no method there that answer the same need.

For example SelectableMapping.getSelectionExpression() will leave the placeholders from the @Formula but it’s not possible to distinguish between replacing the placeholders with the alias from a @Formula or qualifying a basic property with the alias.

Is there a straightforward way, given a SingleTableEntityPersister, a property name and an alias, to get a valid SQL for that property?

In the end I managed to achieve the same result with:

new ColumnReference(
  alias,
  entityPersister.findAttributeMapping(property)
).getColumnExpression();