Package javax.persistence

Examples of javax.persistence.EntityTransaction.begin()


    if (!withoutService)
      return action.execute(method, parameters);
    else {
      EntityTransaction tx = entityManager.getTransaction();
      try {
        tx.begin();
        Object result = action.execute(method, parameters);
        tx.commit();
        return result;
      } catch (Exception e) {
        tx.rollback();
View Full Code Here


      return methodInvocation.proceed();
    }

    //开始一个新的事务
    if(type != TransactionalType.READOLNY){
      transaction.begin();
    }
   
    Object result = null;
    try {
      //执行被拦截的业务方法
View Full Code Here

  }

  final public void testAddFieldvalues() throws Exception {

    EntityTransaction tx = getEntityManager().getTransaction();
    tx.begin();
    Fieldlanguagesvalues flv = new Fieldlanguagesvalues();
    flv.setStarttime(new Date());
    flv.setValue("test");
    flv.setLanguage_id(33L);
    flv.setDeleted("false");
View Full Code Here

    } catch (Exception e) {
      tx.rollback();
      throw new Exception(e.getMessage());
    }

    tx.begin();
    Fieldvalues fl = new Fieldvalues();
    fl.setStarttime(new Date());
    fl.setName("test value");
    fl.setFieldlanguagesvalue(flv);
    fl.setDeleted("false");
View Full Code Here

  }

  final public void testCriteriaBuilder() throws Exception{
    EntityManager em = getEntityManager();
    EntityTransaction tx = em.getTransaction();
    tx.begin();
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Configuration> cq = cb.createQuery(Configuration.class);
    Root<Configuration> c = cq.from(Configuration.class);
    Predicate condition = cb.equal(c.get("deleted"), "false");
    cq.where(condition);
View Full Code Here

      tx.rollback();
      throw new Exception(e.getMessage());
    }

    // add new configuration
    tx.begin();
    Configuration conf = new Configuration();
    conf.setStarttime(new Date());
    conf.setDeleted("false");
    conf.setConf_key("key1");
    conf.setConf_value("value1");
View Full Code Here

    result = q.getResultList();
    assertTrue("result should not be empty", result.size()>0);

    // delete configuration
    Long id = conf.getConfiguration_id();
    tx.begin();
    try {
      conf = getEntityManager().find(Configuration.class, id);
      getEntityManager().remove(conf);
      tx.commit();
    } catch (Exception e) {
View Full Code Here

    eValue.setErrorvalues_id(1L);
    eValue.setErrortype_id(1L);
    eValue.setDeleted("false");
    eValue.setStarttime(new Date());
    eValue.setFieldvalues_id(new Long(322));
    tx.begin();
    try {
      getEntityManager().merge(eValue);
      tx.commit();
    } catch (Exception e) {
      tx.rollback();
View Full Code Here

    Salutations sl = new Salutations();
    sl.setDeleted("false");
    sl.setName("addSalutation");
    sl.setFieldvalues_id(1000L);
    sl.setStarttime(new Date());
    tx.begin();
    try {
      getEntityManager().merge(sl);
      tx.commit();
    } catch (Exception e) {
      tx.rollback();
View Full Code Here

  }
 
  final public void testAddFieldvalues() throws Exception {

    EntityTransaction tx = getEntityManager().getTransaction();
    tx.begin();
    Fieldvalues fl = new Fieldvalues();
    fl.setStarttime(new Date());
    fl.setName("test value");
    fl.setDeleted("false");
    try {
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.