php bin/magento setup:di:compile command throws Source class "-------" for "-------" generation does not exist

After a lot of Code analysis and Google searches, I found the fix for this problem. Adding the following to the di.xml fixed this issue.

<type name="Magento\Framework\Model\Entity\RepositoryFactory">
        <arguments>
            <argument name="entities" xsi:type="array">
                <item name="Namespace\Module\Api\Data\PostInterface" xsi:type="string">Namespace\Module\Api\Data\PostRepositoryInterface
                </item>
            </argument>
        </arguments>
    </type>

Tags:

Magento 2.1