You can also do:

```java
Integer.valueOf(this.getId()).compareTo(that.getId());
```