Package org.hibernate

Examples of org.hibernate.Session.beginTransaction()


        session.getTransaction().commit();
    }
   
    private void updateProcessLog(long processInstanceId) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        List<ProcessInstanceLog> result = session.createQuery(
        "from ProcessInstanceLog as log where log.processInstanceId = ? and log.end is null")
            .setLong(0, processInstanceId).list();
        if (result != null && result.size() != 0) {
          ProcessInstanceLog log = result.get(result.size() - 1);
View Full Code Here


    }
   
    private void addNodeEnterLog(long processInstanceId, String processId, String nodeInstanceId, String nodeId, String nodeName) {
        NodeInstanceLog log = new NodeInstanceLog(NodeInstanceLog.TYPE_ENTER, processInstanceId, processId, nodeInstanceId, nodeId, nodeName);
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        session.save(log);
        session.getTransaction().commit();
    }
   
    private void addNodeExitLog(long processInstanceId, String processId, String nodeInstanceId, String nodeId, String nodeName) {
View Full Code Here

    }
   
    private void addNodeExitLog(long processInstanceId, String processId, String nodeInstanceId, String nodeId, String nodeName) {
        NodeInstanceLog log = new NodeInstanceLog(NodeInstanceLog.TYPE_EXIT, processInstanceId, processId, nodeInstanceId, nodeId, nodeName);
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        session.save(log);
        session.getTransaction().commit();
    }
   
    public void dispose() {
View Full Code Here

    xml = Main.class.getResource("new_hibernate.cfg.xml");
    new_hb = Hibernate.init(xml.getPath());

    Session old_ssn = old_hb.getSession();
    Session new_ssn = new_hb.getSession();
    Transaction tx = new_ssn.beginTransaction();
   
    try{
      upgradeUsers(old_ssn, new_ssn);
      System.out.println("============== Users upgraded.=================");
     
View Full Code Here

public class HibernateDBTest extends TestCase {

  public void testReadHibernate() throws Exception {

    Session session = HibernateHelper.currentSession();
    session.beginTransaction();
    List result = session.createQuery("from Test").list();
    for (int i = 0; i < result.size(); i++) {
      Test tst = (Test) result.get(i);
      System.out.println(tst.getFirstname() + " " + tst.getName());
    }
View Full Code Here

  }

  public void testUpdateHibernate() throws Exception {

    Session session = HibernateHelper.currentSession();
    session.beginTransaction();
    List result = session.createQuery("from Test").list();
    for (int i = 0; i < result.size(); i++) {
      Test tst = (Test) result.get(i);
      tst.setZip(new Integer((int) System.currentTimeMillis()));
    }
View Full Code Here

  public void testWriteHibernate() throws Exception {

    Session session = HibernateHelper.currentSession();

    Transaction tx = session.beginTransaction();

    Test princess = new Test();
    princess.setName("Princess");
    princess.setFirstname("Fiona");
    princess.setId(new Integer(11));
View Full Code Here

    CategoryIF catA = builder.createCategory(null, "News Category");
    Long catId = null;
   
    Transaction tx = null;
    try {
      tx = session.beginTransaction();
      session.save(catA);
      tx.commit();
      catId = new Long(catA.getId());
      System.out.println("Saved category with id " + catId + " persistently");
    }
View Full Code Here

    }
   
    // --- update
    session = handler.getSession();
    try {
      tx = session.beginTransaction();
      Category theCat = (Category) session.load(Category.class, catId);
      theCat.setTitle("Another category title");
      tx.commit();
      System.out.println("Updated category title for id: " + catId);
    } catch (HibernateException he) {
View Full Code Here

    }
   
    // --- list
    session = handler.getSession();
    try {
      tx = session.beginTransaction();
      // Query q = session.createQuery("select cat.id from Category as cat");
      // List result = q.list();
      Query q = session.createQuery("from Category as cat where cat.title = :title");
      q.setParameter("title", "Another category title", Hibernate.STRING);
      List cats = q.list();
View Full Code Here

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.