[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 14:24:39 EDT 2019
On Thu, Apr 25, 2019 at 8:05 PM Steve Ebersole <steve at hibernate.org> wrote:
> 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
>
Thanks.
So I was pretty sure it would work with any provider. My question was more:
how to make it work with multiple providers? Right now, the current
implementation is very low level and doesn't use anything but JPA to get
the EMF. But I didn't see any way to get all the potentially created EMF.
I suppose I could try to get all the EMF from CDI - that would make this
feature CDI-compatible only but I suppose it's acceptable. I will probably
will need to do that after everything is initialized or I will have a
chicken and egg problem as the EMF needs to get the ValidatorFactory. The
thing is that, in this case, all the EMF should be created via CDI or it
won't work very well.
Collecting once and for all all the managed types via
emf.getMetamodel().getManagedTypes() should work.
@Gunnar Morling <gunnar at hibernate.org> does it make sense to you too?
--
Guillaume
More information about the hibernate-dev
mailing list