merge operation does not make the passed entity managed, but rather returns another instance that is managed
so you need to get the id from managed instance as follows
modifiedParentEntity.addChild(newChildEntity);
ModifiedParentEntity modifiedParentManaged= session.merge(modifiedParentEntity);
session.flush()
Then get the child entity from modifiedParentManaged
and then get its id.