Assuming that the return type of getLocationId() is int the below code will work. The proper fix would be to change the signature of getLocationId() to Integer and make sure the code that initializes it sets it to NULL instead of 0