When you use setId() at last, it won't get stored as the manager thinks it doesn't changed. You should do this first and null is the default value which hasn't to be set.