Buggy code:
@ Entity @ Table ( name = "pelanggan" ) public final class Pelanggan extends CodableDomain implements Removable { private String nomorBuku ; private Perusahaan perusahaan ; private String nama ; private String profesi ; private Alamat alamat ; private Kontak kontak ; private Pelanggan . Detail detail ; private Pelanggan . Status status ; private Kelurahan kelurahan ; private List < Pembayaran > listPembayaran ; private Pembayaran pembayaranTerakhir ; public Pelanggan ( ) { } public Pelanggan ( int id , String nomorBuku , Perusahaan perusahaan , String kode , String nama , String profesi , Kelurahan kelurahan , Alamat alamat , Kontak kontak , Pelanggan . Detail detail , Pelanggan . Status status ) throws EmptyCodeException , EmptyIdException { } @ Override @ Id @ GeneratedValue public int getId ( ) { } @ Override @ Column ( name = "kode" ) public String getKode ( ) { } @ Column ( name = "nomor_buku" ) public String getNomorBuku ( ) { } public void setNomorBuku ( String nomorBuku ) { } @ JsonIgnore @ ManyToOne ( fetch = FetchType . EAGER ) @ JoinColumn ( name = "id_perusahaan" , referencedColumnName = "id" ) public Perusahaan getPerusahaan ( ) { } public void setPerusahaan ( Perusahaan perusahaan ) { } @ Column ( name = "nama" ) public String getNama ( ) { } public void setNama ( String nama ) { } @ Column ( name = "profesi" ) public String getProfesi ( ) { } public void setProfesi ( String profesi ) { } @ JsonIgnore @ Embedded public Alamat getAlamat ( ) { } public void setAlamat ( Alamat alamat ) { } private void setAlamat ( ) { } @ JsonIgnore @ Embedded public Kontak getKontak ( ) { } public void setKontak ( Kontak kontak ) { } private void setKontak ( ) { } @ JsonIgnore @ Embedded public Pelanggan . Detail getDetail ( ) { } public void setDetail ( Pelanggan . Detail detail ) { } private void setDetail ( ) { } @ Column ( name = "status" ) public Pelanggan . Status getStatus ( ) { } public void setStatus ( Pelanggan . Status status ) { } @ JsonIgnore @ ManyToOne ( fetch = FetchType . EAGER ) @ JoinColumn ( name = "id_kelurahan" , referencedColumnName = "id" ) public Kelurahan getKelurahan ( ) { } public void setKelurahan ( Kelurahan kelurahan ) { } private void setKelurahan ( ) { } @ JsonIgnore @ OneToMany ( targetEntity = Pembayaran . class , mappedBy = "pelanggan" , fetch = FetchType . LAZY , cascade = { CascadeType . REMOVE } ) public List < Pembayaran > getListPembayaran ( ) { } public void setListPembayaran ( List < Pembayaran > listPembayaran ) { } @ JsonIgnore @ OneToOne ( fetch = FetchType . EAGER ) @ JoinColumn ( name = "pembayaran_terakhir" , referencedColumnName = "id" ) public Pembayaran getPembayaranTerakhir ( ) { } public void setPembayaranTerakhir ( Pembayaran pembayaranTerakhir ) { } private void setPembayaranTerakhir ( ) { } @ Transient public int getIdPembayaranTerakhir ( ) { <START_BUG> if ( ( pembayaranTerakhir ) == null ) <END_BUG> return pembayaranTerakhir . getId ( ) ; return 0 ; } public void setIdPembayaranTerakhir ( int id ) { } @ Transient public String getNamaKelurahan ( ) { } public void setNamaKelurahan ( String namaKelurahan ) { } @ Transient public int getIdKelurahan ( ) { } public void setIdKelurahan ( int idKelurahan ) throws EmptyIdException { } @ Transient public String getNamaKecamatan ( ) { } public void setNamaKecamatan ( String namaKecamatan ) { } @ Transient public int getIdKecamatan ( ) { } public void setIdKecamatan ( int idKecamatan ) throws EmptyIdException { } @ Transient public String getNamaKota ( ) { } public void setNamaKota ( String namaKota ) { } @ Transient public int getIdKota ( ) { } public void setIdKota ( int idKota ) throws EmptyIdException { } @ Transient public int getLingkungan ( ) { } public void setLingkungan ( int lingkungan ) { } @ Transient public String getDetailAlamat ( ) { } public void setDetailAlamat ( String detailAlamat ) { } @ Transient public float getLatitude ( ) { } public void setLatitude ( float latitude ) { } @ Transient public float getLongitude ( ) { } public void setLongitude ( float longitude ) { } @ Transient public String getTelepon ( ) { } public void setTelepon ( String telepon ) { } @ Transient public String getHp ( ) { } public void setHp ( String hp ) { } @ Transient public String getEmail ( ) { } public void setEmail ( String email ) { } @ JsonIgnore @ Transient public Date getTanggalMulai ( ) { } public void setTanggalMulai ( Date tanggalMulai ) { } @ Transient public String getTanggalMulaiStr ( ) { } public void setTanggalMulaiStr ( String tanggalMulaiStr ) { } @ Transient public int getJumlahTv ( ) { } public void setJumlahTv ( int jumlahTv ) { } @ Transient public long getIuran ( ) { } public void setIuran ( long iuran ) { } @ Transient public int getTunggakan ( ) { } public void setTunggakan ( int tunggakan ) { } public int countTunggakan ( ) { } public int countDefaultTunggakan ( ) { } public int countTunggakan ( Tagihan tagihan ) { } @ Override public void remove ( ) throws StatusChangeException { } @ Override @ JsonIgnore public int hashCode ( ) { } @ Override @ JsonIgnore public boolean equals ( Object obj ) { } @ Override @ JsonIgnore public String toString ( ) { } @ Embeddable public static final class Detail { private Date tanggalMulai ; private int jumlahTv ; private long iuran ; private int tunggakan ; public Detail ( ) { } public Detail ( Date tanggalMulai , int jumlahTv , long iuranBulanan , int tunggakan ) { }

Fix:
if ( ( pembayaranTerakhir ) != null )