Package testy

Source Code of testy.Main

package testy;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import pakiet.Stanowisko;

public class Main {

  /**
   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    Configuration configure = new Configuration()
        .configure("pakiet/hibernate.cfg.xml");
    // configure.setInterceptor(new Interceptor());
    // configure.getEventListeners().setPreUpdateEventListeners(
    // new PreUpdateEventListener[] { new PreUpdateListener() });
    // configure.getEventListeners().setLoadEventListeners(
    // new LoadEventListener[] { new LoadListener(),
    // new DefaultLoadEventListener() });
    final SessionFactory sessionFactory = configure.buildSessionFactory();
    // Session session = sessionFactory.openSession();
    // Transaction transaction = session.beginTransaction();
    // session.createQuery("from Stanowisko").list();
    // Stanowisko s = (Stanowisko) session.load(Stanowisko.class, 1);
    // s.setNazwa(System.currentTimeMillis() + " miro");
    // System.out.println(s.getNazwa());
    // session
    // .createQuery(
    // "update Pracownik s SET s.imie='haha2222' where s.idPracownik<2")
    // .executeUpdate();
    // int executeUpdate = session.createQuery(
    // "Update Pracownik Set imie ='sdfc' where imie like '%afsd'")
    // .executeUpdate();
    // System.out.println("ilosc = " + executeUpdate);
    // transaction.commit();

    // Session session2 = sessionFactory.openSession();
    // Transaction transaction2 = session2.beginTransaction();
    // // Stanowisko s2 = (Stanowisko) session2.load(Stanowisko.class, 1);
    // Pracownik p = (Pracownik) session2.load(Pracownik.class, 2);
    // System.out.println(p.getStanowisko().getNazwa());

    JFrame jf = new JFrame();
    jf.setSize(100, 100);
    jf.setVisible(true);
    JButton jbButton = new JButton();
    jbButton.setText("mirek");
    jbButton.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent e) {
        Stanowisko s = (Stanowisko) sessionFactory.openSession().load(
            Stanowisko.class, 1);
        System.out.println(s.getNazwa());

      }
    });
    jf.add(jbButton);

  }
}
TOP

Related Classes of testy.Main

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.