Package io.jmix.data
Interface ReferenceIdProvider
- All Known Implementing Classes:
EclipselinkReferenceIdProvider
public interface ReferenceIdProvider
Enables working with references to entities without loading them from the database.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA wrapper for the reference ID value returned bygetReferenceId(Object, String)method. -
Method Summary
Modifier and TypeMethodDescriptiongetReferenceId(Object entity, String property) Returns an ID of directly referenced entity without loading it from DB.
-
Method Details
-
getReferenceId
Returns an ID of directly referenced entity without loading it from DB.If the fetchPlan does not contain the reference and
FetchPlan.loadPartialEntities()is true, the returnedReferenceIdProvider.RefIdwill haveReferenceIdProvider.RefId.isLoaded()= false.Usage example:
ReferenceIdProvider.RefId refId = referenceIdProvider.getReferenceId(doc, "currency"); if (refId.isLoaded()) { String currencyCode = (String) refId.getValue(); }- Parameters:
entity- entity instance in managed stateproperty- name of reference property- Returns:
ReferenceIdProvider.RefIdinstance which contains the referenced entity ID- Throws:
IllegalArgumentException- if the specified property is not a referenceIllegalStateException- if the entity is not in Managed stateRuntimeException- if anything goes wrong when retrieving the ID
-