Fix equals method for BaseEntity

Small bug in the equals method of BaseEntity. If an entity doesn't have an id, it is a newly created object (not yet saved). So it cannot be equals to another object without id except if this second object is itself