is it possible to access the information in <persistence-unit-metadata>
through Java API?
<persistence-unit-metadata>
<persistence-unit-defaults>
<schema>MySchema</schema>
</persistence-unit-defaults>
</persistence-unit-metadata>
I would like to read the schema "MySchema" via JPA API or EclipseLink API, which is the implementation I use.
Something like: entityManager.getDefaults().getSchema(); It's OK to cast or use any EclipseLink class, that's fine for this.
Thank you
After debugging for a while I found a solution to access the schema of an entity.
EntityType<MyEntity> entity = emf.getMetamodel().entity(MyEntity.class);
EntityTypeImpl entityTypeImpl = (EntityTypeImpl) entity;
ClassDescriptor descriptor = entityTypeImpl.getDescriptor();
String schema = descriptor.getDefaultTable().getTableQualifier();
Looking for an easier and better way to access the information! Thank you so much.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With