public X getPrimaryID ( T entity ) { if ( mappingContext == null || conversionService == null ) { fetchMappingContextAndConversionService ( ) ; } MongoPersistentEntity < ? > persistentEntity = mappingContext . getPersistentEntity ( entity . getClass ( ) ) ; MongoPersistentProperty idProperty = persistentEntity . getIdProperty ( ) ; if ( idProperty == null ) { return null ; } // X idValue = BeanWrapper.create(entity, conversionService).getProperty(idProperty, this.primaryIDClass); X idValue = ( X ) this . mappingContext . getPersistentEntity ( this . entityClass ) . getPropertyAccessor ( entity ) . getProperty ( idProperty ) ; return idValue ; }
Extract the value of the primary ID of the entity object