private NodeBuilder buildNode(Object entity, PersistenceDelegator pd, Object entityId, String nodeId)
{
Node nodeInPersistenceCache = pd.getPersistenceCache().getMainCache().getNodeFromCache(nodeId, pd);
EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(pd.getKunderaMetadata(),
entity.getClass());
// TODO: in case of composite key. it is a bit hack and should be
// handled better.
if (nodeInPersistenceCache == null)
{
this.state = state != null ? this.state : new TransientState();
node = new Node(
nodeId,
entity,
((Field) entityMetadata.getIdAttribute().getJavaMember()).isAnnotationPresent(EmbeddedId.class) ? new ManagedState()
: this.state, pd.getPersistenceCache(), entityId, pd);
}
else
{
node = nodeInPersistenceCache;