assigned id is when you do not have autogenerated keys.
entity.setChild(new ChildEntity(childId)) is rather bad since why do you want to have an incomplete objectgraph?
better approach is:
entity.setChild(session.load(ChildEntity.class, childId));
That will do the same thing and wont load the childentity unless you try to access methods on it avoiding incomplete objectgraph.