Annotation equivalent of <any> mapping with no discriminators configured

We are migrating a legacy application to Hibernate ORM 6.2, moving from XML configuration to annotations. We have the following audit-related property defined for which we cannot determine the equivalent annotations to achieve the automatic persisting of the entity class name and id.

    <any name="audit" id-type="long" cascade="save-update">
      <column name="audit_class" />
      <column name="audit_class_id" />
    </any>

We’ve got the following in our Entity which only persists the ID of the audit object and not the class name

  @Any
  @Cascade(CascadeType.SAVE_UPDATE)
  @Column(name = "audit_class")
  @AnyKeyJavaClass(value = Long.class)
  @JoinColumn(name = "audit_class_id")
  protected Object audit;

Short of defining a huge list of @AnyDiscriminatorValue entries, with the added of complexity of the Entity class not currently having visibility to them, is there an equivalent to retain the mapping of the entity class type and id automatically with annotations?

If you can point us to past documentation that explicitly mentioned this as being supported, then you create a JIRA bug report for this. To me, this looks like something which might have worked by accident. At least we don’t have test for this particular kind of mapping.

I’ve managed to track down mention of this behaviour in a copy of the 2.1.7 documentation i found here
https://www.immagic.com/eLibrary/ARCHIVES/SUPRSDED/JBOSS_US/H050223R.pdf. It explicitly lists an <any> mapping without any <meta-value>

<any name="anyEntity" id-type="long" meta-type="eg.custom.Class2TablenameType">
<column name="table_name"/>
<column name="id"/>
</any>

The meta-type attribute lets the application specify a custom type that maps database column values to persist-
ent classes which have identifier properties of the type specified by id-type. If the meta-type returns instances
of java.lang.Class, nothing else is required

Given support for this has dropped between v5 and v6, we can work around this given it’s now doesn’t work.

I created [HHH-16620] - Hibernate JIRA for this, but to be honest with you, I doubt that we will implement this soon, so you should rather workaround it for now.