incomparable types: java.lang.string and int

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bamsThomas212
    New Member
    • Sep 2012
    • 1

    incomparable types: java.lang.string and int

    I wanted to ask about the code that I have made if either variable or any of ... thank you ...
    "incomparab le types: java.lang.strin g and int"
    Code:
     if(StringUtils.isNullOrEmpty(txtIdPemesanan.getText())){
            JOptionPane.showMessageDialog(null, "ID pemesanan tidak boleh kosong", "Larangan", JOptionPane.ERROR_MESSAGE);
        }else{
            pemesanan = pemesananController.findPemesanan(txtIdPemesanan.getText());
            [B][U]if (pemesanan.getIdPemesanan()== 0)[/U][/B] {
                JOptionPane.showMessageDialog(null, "Data yang dicari tidak ada!");
            }else{
            txtIdMarketing.setText(pemesanan.getMarketingIdmarketing()+"");
            jDatePemesanan.setDate(pemesanan.getTanggal());
            txtIdCustomer.setText(pemesanan.getCustomerIdcustomer()+"");
            
            CustomerJpaController customerController = new CustomerJpaController(emf);
            Customer customer = customerController.findCustomer(pemesanan.getCustomerIdcustomer());
            txtNamaCustomer.setText(customer.getNmCustomer());
            
            DetilbarangJpaController detilBarangController = new DetilbarangJpaController(emf);
                javax.persistence.Query namedQuery = detilBarangController.getEntityManager().createNamedQuery("Detilbarang.findByPemesananIdPemesanan");
            namedQuery.setParameter("pemesananIdPemesanan", pemesanan.getIdPemesanan());
            List<Detilbarang> listDetilBarang = namedQuery.getResultList();
            DefaultTableModel model = (DefaultTableModel) tblDetilBarang.getModel();
            int i = 0;
            while (i < tblDetilBarang.getRowCount()){
                model.removeRow(i);

    thanks for helpme...... :)
    Last edited by Rabbit; Nov 6 '12, 04:15 PM.
  • PreethiGowri
    New Member
    • Oct 2012
    • 126

    #2
    i guess you are comparing a string with integer value 0
    if you want to compare a string then use,

    pemesanan.getId Pemesanan() == null

    Comment

    Working...