[hibernate-dev] [ORM] Do we have a way to check if an object is an entity?

Guillaume Smet guillaume.smet at gmail.com
Thu Apr 25 13:14:15 EDT 2019


In Hibernate Validator, we have a TraversableResolver which avoids to
validate the uninitialized properties of an entity.

This is done in
and, as you can see, we execute Persistence.getPersistenceUtil().isLoaded(
traversableObject, traversableProperty.getName() ) even if the
traversableObject has nothing to do with Hibernate ORM.

I'm looking for an API that could tell me if an object is a class
potentially managed by ORM (be it an entity, an embeddable or whatever: any
class potentially containing a lazy field).

I was thinking that maybe injecting an EntityManagerFactory (it would
require CDI though) and using the Metamodel could somehow work... but the
PersistenceUtil API we currently use is capable of dealing with several
persistence providers and I don't think the injected EntityManagerFactory
approach will fly in this case.

Is there something I could use to do that, that would be portable and cover
the cases currently (somehow) taken care of?

Any ideas welcome.



More information about the hibernate-dev mailing list