Why is java.util.Map a managed type for Hibernate when entity is audited?

We try to use the list of managed types to decide if we need to pass a target class to the JPA implementation when executing a query coming from a @Query annotation.

If the return type of the method is a managed type we assume the user wrote the query in such a way that JPA returns that entity.
If not we request a Tuple and construct the result ourself.

Map suddenly appearing in the managed types makes Map-returning-methods behave differently (and actually fail) depending on the usage of Envers.

I guess on our side we do have a couple of options to fine tune that check:

  • only consider ManageTypes that have a JavaType and an EntityName
  • or just those with origin ORM. Depending on what is available in the API
  • special handling for Maps

come to my mind.

I guess the real problem is that I so far didn’t find a clear definition what being a managed type even mean exactly. Preferably that would come from the JPA spec of course.