public interface ReferenceIdProvider
Modifier and Type | Interface and Description |
---|---|
static class |
ReferenceIdProvider.RefId
A wrapper for the reference ID value returned by
getReferenceId(Object, String) method. |
Modifier and Type | Method and Description |
---|---|
ReferenceIdProvider.RefId |
getReferenceId(java.lang.Object entity,
java.lang.String property)
Returns an ID of directly referenced entity without loading it from DB.
|
ReferenceIdProvider.RefId getReferenceId(java.lang.Object entity, java.lang.String property)
If the fetchPlan does not contain the reference and FetchPlan.loadPartialEntities()
is true,
the returned ReferenceIdProvider.RefId
will have ReferenceIdProvider.RefId.isLoaded()
= false.
Usage example:
ReferenceIdProvider.RefId refId = referenceIdProvider.getReferenceId(doc, "currency"); if (refId.isLoaded()) { String currencyCode = (String) refId.getValue(); }
entity
- entity instance in managed stateproperty
- name of reference propertyReferenceIdProvider.RefId
instance which contains the referenced entity IDjava.lang.IllegalArgumentException
- if the specified property is not a referencejava.lang.IllegalStateException
- if the entity is not in Managed statejava.lang.RuntimeException
- if anything goes wrong when retrieving the ID