Makes sure only locked records are changed

There were an issue in RelationshipCreator where, during upgrading a node
to dense representation, some relationships might be read and marked for
changing before they were locked. This could lead to changes being applied
to stale record data.

This commit also fixes other unrelated issues:
 o Getting node degree for a relationship type that didn't exist would be
   mistakedly interpreted as getting the degree for all relationships for
   that node.
 o BatchInserter#getRelationshipIds/getRelationships didn't regard dense
   node representations and so invalid relationships where returned for
   dense nodes.