EMF + Metamodel are standard JPA contracts: ```` try { emf.getMetamodel().managedType( theClass ); } catch ( IllegalArgumentException e ) { // JPA defined exception if the passed class is not a managed type } ````
Again, that will (should) work on any provider On Thu, Apr 25, 2019 at 1:01 PM Guillaume Smet <guillaume.s...@gmail.com> wrote: > Hi, > > In Hibernate Validator, we have a TraversableResolver which avoids to > validate the uninitialized properties of an entity. > > This is done in > > https://github.com/hibernate/hibernate-validator/blob/master/engine/src/main/java/org/hibernate/validator/internal/engine/resolver/JPATraversableResolver.java#L35 > 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. > > Thanks! > > -- > Guillaume > _______________________________________________ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/hibernate-dev > _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev