If you call getLastInsertedId without inserting a record first then, this method returns null since internally postgresql returns null.