Example usage for org.hibernate Query iterate

List of usage examples for org.hibernate Query iterate

Introduction

In this page you can find the example usage for org.hibernate Query iterate.

Prototype

Iterator<R> iterate();

Source Link

Document

Return the query results as an Iterator.

Usage

From source file:controller.KullaniciIslemleri.java

public void KullaniciSil(String username) {
    String QUERY = "from kullanici";
    int sil = 0;// ww  w. j av  a  2  s.  c  o  m
    org.hibernate.Query sorgu = session.createQuery(QUERY);
    Iterator it = sorgu.iterate();
    ArrayList<kullanici> liste = new ArrayList();
    while (it.hasNext()) {
        kullanici usr = (kullanici) it.next();
        liste.add(usr);
    }

    for (int i = 0; i < liste.size(); i++) {
        if (liste.get(i).getUsername().equals(username)) {
            sil = 1;
        }
    }
    if (sil == 1) {
        try {
            Query query = session.createQuery("delete from kullanici where username=:username");
            query.setString("username", username);
            query.executeUpdate();
            System.out.println(query.executeUpdate());
            if (username.equals("Admin"))
                JOptionPane.showMessageDialog(null, "Admin silinemez!");
            else
                ts.commit();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "nce bu kullancya ait personeli siliniz\n " + ex);
        }
    } else if (sil == 0) {
        JOptionPane.showMessageDialog(null, "Byle bir kullanc ad mecut deil");
    }
}

From source file:controller.MarkaIslemeri.java

public void markaEkle(marka mrk) {
    String QUERY = "from  marka";
    int ekle = 0;
    org.hibernate.Query sorgu = session.createQuery(QUERY);
    Iterator it = sorgu.iterate();
    ArrayList<marka> liste = new ArrayList();
    while (it.hasNext()) {
        marka mrk2 = (marka) it.next();/*  www  .  j ava  2  s .  co  m*/
        liste.add(mrk2);
    }
    for (int i = 0; i < liste.size(); i++) {
        if (liste.get(i).getM_adi().equals(mrk.getM_adi())) {
            JOptionPane.showMessageDialog(null, "Bu Marka Zaten Mevcut");
            ekle = 1;
        }
    }

    if (ekle == 0) {
        session.saveOrUpdate(mrk);
        ts.commit();
    }
}

From source file:controller.MarkaIslemeri.java

public String[] markaGetir() {
    String QUERY = "from  marka";
    int ekle = 0;
    org.hibernate.Query sorgu = session.createQuery(QUERY);
    Iterator it = sorgu.iterate();
    ArrayList<marka> liste = new ArrayList();
    while (it.hasNext()) {
        marka mrk2 = (marka) it.next();/*  w w  w . j a  va2s . co  m*/
        liste.add(mrk2);
    }
    String obj[] = new String[liste.size()];
    for (int i = 0; i < liste.size(); i++) {
        obj[i] = liste.get(i).getM_adi();

    }
    return obj;
}

From source file:controller.MusteriIslemleri.java

public int musteriSil(String m_id) {
    String QUERY = "from musteri";
    int sil = 0;//w w w  .  j a  v a 2 s.c om
    org.hibernate.Query sorgu = session.createQuery(QUERY);
    Iterator it = sorgu.iterate();
    ArrayList<musteri> liste = new ArrayList();
    while (it.hasNext()) {
        musteri mstri = (musteri) it.next();
        liste.add(mstri);
    }
    for (int i = 0; i < liste.size(); i++) {
        if (Integer.toString(liste.get(i).getM_id()).equals(m_id))

            sil = 1;
    }
    if (sil == 0) {
        return sil;

    } else {
        try {
            Query query = session.createQuery("delete from musteri where m_id=:m_id");
            query.setString("m_id", m_id);
            query.executeUpdate();
            ts.commit();
            return sil;
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Bir hata var " + e);
        }

    }
    return sil;
}

From source file:controller.MusteriIslemleri.java

public DefaultTableModel musteriGetir() {
    String QUERY = "from musteri";

    org.hibernate.Query sorgu = session.createQuery(QUERY);
    Iterator it = sorgu.iterate();
    ArrayList<musteri> liste = new ArrayList();
    DefaultTableModel tm = new DefaultTableModel();
    while (it.hasNext()) {
        musteri mstri = (musteri) it.next();

        liste.add(mstri);/*w  w  w. j  a  v a 2  s  .  c o m*/
    }

    tm.addColumn("Musteri No");
    tm.addColumn("Adi");
    tm.addColumn("Soyadi");
    tm.addColumn("Telefon");
    tm.addColumn("Adres");
    tm.addColumn("Bor");
    tm.addColumn("skonto");

    for (int j = 0; j < liste.size(); j++) {
        tm.addRow(new Object[] { liste.get(j).getM_id(), liste.get(j).getM_adi(), liste.get(j).getM_soyadi(),
                liste.get(j).getM_telefon(), liste.get(j).getM_adres(), liste.get(j).getM_borc(),
                liste.get(j).getM_iskonto() });

    }

    return tm;
}

From source file:controller.PersoneIslemleri.java

public void personelEkle(personel prsnl) {
    String QUERY = "from personel";
    int ekle = 0;
    org.hibernate.Query sorgu = session.createQuery(QUERY);
    Iterator it = sorgu.iterate();
    ArrayList<personel> liste = new ArrayList();
    while (it.hasNext()) {
        personel prsnl2 = (personel) it.next();
        liste.add(prsnl2);/*from w  ww .j  av a  2s  .com*/
    }
    for (int i = 0; i < liste.size(); i++) {
        if (liste.get(i).getK_id() == prsnl.getK_id()) {
            JOptionPane.showMessageDialog(null, "Bu kullanc numaras kullanlmaktadr..!");
            ekle = 1;
        }
    }

    if (ekle == 0) {
        session.saveOrUpdate(prsnl);
        ts.commit();
    }
}

From source file:controller.PersoneIslemleri.java

public int personelSil(String p_id) {
    String QUERY = "from personel";
    int sil = 0;// ww w.java  2s .com
    org.hibernate.Query sorgu = session.createQuery(QUERY);
    Iterator it = sorgu.iterate();
    ArrayList<personel> liste = new ArrayList();
    while (it.hasNext()) {
        personel prsnl = (personel) it.next();
        liste.add(prsnl);
    }
    for (int i = 0; i < liste.size(); i++) {
        if (Integer.toString(liste.get(i).getP_id()).equals(p_id))

            sil = 1;
    }
    if (sil == 0) {
        return sil;

    } else {
        try {
            Query query = session.createQuery("delete from personel where p_id=:p_id");
            query.setString("p_id", p_id);
            query.executeUpdate();
            ts.commit();
            return sil;
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Bir hata var " + e);
        }

    }
    return sil;
}

From source file:controller.PersoneIslemleri.java

public DefaultTableModel PersonelGetir() {
    SessionFactory sf = HibernateUtil.getSessionFactory();
    Session session = sf.openSession();//from  w  w w .j ava2s .  c o m
    String QUERY = "from personel";

    org.hibernate.Query sorgu = session.createQuery(QUERY);
    Iterator it = sorgu.iterate();
    ArrayList<personel> liste = new ArrayList();
    DefaultTableModel tm = new DefaultTableModel();
    while (it.hasNext()) {
        personel persnl = (personel) it.next();

        liste.add(persnl);
    }
    tm.addColumn("Persnl No");
    tm.addColumn("Ad");
    tm.addColumn("Soyad");
    tm.addColumn("Telefon");
    tm.addColumn("Adres");
    tm.addColumn("Maa");
    tm.addColumn("Puantaj");
    tm.addColumn("k_id");

    for (int j = 0; j < liste.size(); j++) {
        tm.addRow(new Object[] { liste.get(j).getP_id(), liste.get(j).getP_adi(), liste.get(j).getP_soyadi(),
                liste.get(j).getP_telefon(), liste.get(j).getP_adresi(), liste.get(j).getP_maas(),
                liste.get(j).getP_puantaj(), liste.get(j).getK_id() });
    }
    return tm;
}

From source file:controller.SatisIslemleri.java

public void SatisYap(model.stok_satis satis) {

    session.saveOrUpdate(satis);//from   w  ww. j av  a  2  s .  c om
    String QUERY = "select u_adet from urun where u_barkod= :u_kod";
    org.hibernate.Query sorgu = session.createQuery(QUERY);
    sorgu.setParameter("u_kod", satis.getU_kod());
    Iterator it = sorgu.iterate();
    session.saveOrUpdate(satis);
    ts.commit();
}

From source file:controller.UrunIslemleri.java

public void urunEkle(urun gelenUrn) {
    String QUERY = "from urun";
    int ekle = 0;
    org.hibernate.Query sorgu = session.createQuery(QUERY);
    Iterator it = sorgu.iterate();
    ArrayList<urun> liste = new ArrayList();
    while (it.hasNext()) {
        urun urn = (urun) it.next();//w w  w  .  j a  v  a 2  s. com
        liste.add(urn);
    }
    for (int i = 0; i < liste.size(); i++) {
        if (liste.get(i).getU_barkod() == gelenUrn.getU_barkod()) {
            JOptionPane.showMessageDialog(null, "Bu Urun Zaten Mevcut");
            ekle = 1;
        }
    }

    if (ekle == 0) {
        session.saveOrUpdate(gelenUrn);
        ts.commit();
    }
}