EntityMetadata entityMetadata = getMetadata(entityClass);
String nodeId = ObjectGraphUtils.getNodeId(primaryKey, entityClass);
// TODO all the scrap should go from here.
MainCache mainCache = (MainCache) getPersistenceCache().getMainCache();
Node node = mainCache.getNodeFromCache(nodeId, this);
// if node is not in persistence cache or is dirty, fetch from database
if (node == null || node.isDirty())
{
node = new Node(nodeId, entityClass, new ManagedState(), getPersistenceCache(), primaryKey, this);