当前位置: 首页>>代码示例>>Java>>正文


Java Transaction.isActive方法代码示例

本文整理汇总了Java中javax.jdo.Transaction.isActive方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.isActive方法的具体用法?Java Transaction.isActive怎么用?Java Transaction.isActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jdo.Transaction的用法示例。


在下文中一共展示了Transaction.isActive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doRollback

import javax.jdo.Transaction; //导入方法依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status) {
	JdoTransactionObject txObject = (JdoTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Rolling back JDO transaction on PersistenceManager [" +
				txObject.getPersistenceManagerHolder().getPersistenceManager() + "]");
	}
	try {
		Transaction tx = txObject.getPersistenceManagerHolder().getPersistenceManager().currentTransaction();
		if (tx.isActive()) {
			tx.rollback();
		}
	}
	catch (JDOException ex) {
		throw new TransactionSystemException("Could not roll back JDO transaction", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:JdoTransactionManager.java

示例2: dropUser

import javax.jdo.Transaction; //导入方法依赖的package包/类
@Override
public void dropUser(String name) throws MetaException {
    Transaction tx = pm.currentTransaction();
    try {
        tx.begin();

        pm.deletePersistent(getUser(name));

        tx.commit();
    } catch (RuntimeException e) {
        throw new MetaException("failed to drop user '" + name + "'", e);
    } finally {
        if (tx.isActive())
            tx.rollback();
    }
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:17,代码来源:JDOMetaContext.java

示例3: deletePeriodPreferences

import javax.jdo.Transaction; //导入方法依赖的package包/类
@Override
public void deletePeriodPreferences(String key) {
	LOG.log(Level.INFO,"deletePeriodPreferences() "+key);		
	Transaction tx=null;
	PersistenceManager pm=getPm();
	try {
		tx = pm.currentTransaction();
		tx.begin();
		GaePeriodPreferencesBean result 
			= pm.getObjectById(GaePeriodPreferencesBean.class, ServerUtils.stringToKey(key));
		pm.deletePersistent(result);
		tx.commit();
		LOG.log(Level.INFO,"  Deleted!");
	} finally {
        if (tx!=null && tx.isActive()) {
            tx.rollback();
        }
		pm.close();
	}
}
 
开发者ID:dvorka,项目名称:shifts-solver,代码行数:21,代码来源:GaePersistence.java

示例4: putSlide

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
    * Put Slide into datastore.
    * Stores the given Slide instance in the datastore for this
    * program.
    * @param programKey
    * 			: the key of the Program where the slide will be added
    * @param slide
    * 			: the Slide instance to program
    */
public static void putSlide(Key programKey, Slide slide) {
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Program program = 
				pm.getObjectById(Program.class, programKey);
		Channel channel =
				pm.getObjectById(Channel.class, programKey.getParent());
		tx.begin();
		program.addSlide(slide);
		channel.updateProgramVersion();
		tx.commit();
		log.info("Slide stored successfully in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:32,代码来源:SlideManager.java

示例5: removeSystemPrivileges

import javax.jdo.Transaction; //导入方法依赖的package包/类
@Override
public void removeSystemPrivileges(List<SystemPrivilege> sysPrivs, List<String> userNames) throws MetaException {
    Transaction tx = pm.currentTransaction();
    try {
        tx.begin();

        for (String userName : userNames) {
            MUser mUser = (MUser) getUser(userName);
            for (SystemPrivilege sysPriv : sysPrivs)
                mUser.removeSystemPrivilege(sysPriv);

            pm.makePersistent(mUser);
        }

        tx.commit();
    } catch (Exception e) {
        throw new MetaException("failed to remove system privileges from users", e);
    } finally {
        if (tx.isActive())
            tx.rollback();
    }
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:23,代码来源:JDOMetaContext.java

示例6: updateRegionAttributes

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Update Region attributes.
   * Update's the given region's attributes in the datastore.
   * @param key
   * 			: the key of the region whose attributes will be updated
   * @param regionName
   * 			: the new name to give to the region
   * @param regionComments
   * 			: the new comments to give to the region
* @throws MissingRequiredFieldsException 
   */
public static void updateRegionAttributes(Long key, String regionName,
		String regionComments) throws MissingRequiredFieldsException {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Region region = pm.getObjectById(Region.class, key);
		tx.begin();
		region.setRegionName(regionName);
		region.setRegionComments(regionComments);
		tx.commit();
		log.info("Region \"" + regionName + "\"'s attributes updated in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:33,代码来源:RegionManager.java

示例7: savePeriodSolution

import javax.jdo.Transaction; //导入方法依赖的package包/类
@Override
public PeriodSolution savePeriodSolution(PeriodSolution bean) {
	LOG.log(Level.INFO,"savePeriodSolution() "+bean.toString());
	
	GaePeriodSolutionBean gaeResult=new GaePeriodSolutionBean();
	gaeResult.fromPojo(bean);
	gaeResult.setModified(System.currentTimeMillis());
	
	PersistenceManager pm = getPm();
	Transaction tx=null;
	try {
		tx = pm.currentTransaction();
		tx.begin();
		gaeResult = (GaePeriodSolutionBean)pm.makePersistent(gaeResult);
		tx.commit();
	} finally {
        if (tx!=null && tx.isActive()) {
            tx.rollback();
        }
        pm.close();
	}
	
	return gaeResult.toPojo();
}
 
开发者ID:dvorka,项目名称:shifts-solver,代码行数:25,代码来源:GaePersistence.java

示例8: putChannel

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Add channel to a Station.
   * Add a new channel in the datastore for this Station.
   * @param email
   * 			: the email of the Station where the channel will be added
   * @param channel
   * 			: the channel to be added
   */
public static void putChannel(Email stationEmail, Channel channel) {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Key key = KeyFactory.createKey(Station.class.getSimpleName(), 
				stationEmail.getEmail());
		Station station = pm.getObjectById(Station.class, key);
		tx.begin();
		station.addChannel(channel);
		tx.commit();
		log.info("Channel \"" + channel.getChannelName() + "\" added to Station \"" + 
				stationEmail.getEmail() + "\" in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:31,代码来源:ChannelManager.java

示例9: putProgram

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
    * Put Program into datastore.
    * Stores the given Program instance in the datastore for this
    * channel.
    * @param channelKey
    * 			: the key of the Channel where the program will be added
    * @param program
    * 			: the Program instance to channel
    */
public static void putProgram(Key channelKey, Program program) {
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Channel channel = 
				pm.getObjectById(Channel.class, channelKey);
		tx.begin();
		channel.addProgram(program);
		channel.updateProgramVersion();
		tx.commit();
		log.info("Program \"" + program.getProgramName() + 
			"\" stored successfully in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:31,代码来源:ProgramManager.java

示例10: savePeriodPreferences

import javax.jdo.Transaction; //导入方法依赖的package包/类
@Override
public PeriodPreferences savePeriodPreferences(PeriodPreferences bean) {
	LOG.log(Level.INFO,"savePeriodPreferences() "+bean.toString());
	
	GaePeriodPreferencesBean gaeResult=new GaePeriodPreferencesBean();
	gaeResult.fromPojo(bean);
	gaeResult.setModified(System.currentTimeMillis());
	
	PersistenceManager pm = getPm();
	Transaction tx=null;
	try {
		tx = pm.currentTransaction();
		tx.begin();
		gaeResult = (GaePeriodPreferencesBean)pm.makePersistent(gaeResult);
		tx.commit();
	} finally {
        if (tx!=null && tx.isActive()) {
            tx.rollback();
        }
        pm.close();
	}
	
	return gaeResult.toPojo();
}
 
开发者ID:dvorka,项目名称:shifts-solver,代码行数:25,代码来源:GaePersistence.java

示例11: updatePlaylistAttributes

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Update Playlist attributes.
   * Updates the given Playlist's attributes in the datastore.
   * @param key
   * 			: the key of the Playlist whose attributes will be updated
   * @param playlistName
   * 			: the new name to give to the Playlist
* @throws MissingRequiredFieldsException
   */
public static void updatePlaylistAttributes(Key key, String playlistName)
		throws MissingRequiredFieldsException {
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Playlist playlist = pm.getObjectById(Playlist.class, key);
		Station station = pm.getObjectById(Station.class, key.getParent());
		tx.begin();
		playlist.setPlaylistName(playlistName);
		station.updatePlaylistVersion();
		tx.commit();
		log.info("Playlist \"" + playlistName + "\"'s attributes updated in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:32,代码来源:PlaylistManager.java

示例12: save

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
 * Makes the given entity persistent.
 * @param entity Persistent capable entity.
 * @return Corresponding persistent entity.
 */
public T save(T entity) {
	PersistenceManager pm = PMF.get().getPersistenceManager();
	Transaction tx = pm.currentTransaction();
	try {
		tx.begin();
		T result = pm.makePersistent(entity);
		tx.commit();
		return result;
	} finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:biegleux,项目名称:gae-oauth-tokenstore,代码行数:21,代码来源:JDORepository.java

示例13: updateExistingTask

import javax.jdo.Transaction; //导入方法依赖的package包/类
private String updateExistingTask(Task existingTask) {
  String taskId = null;
  PersistenceManager pm = pmf.getPersistenceManager();
  Transaction tx = pm.currentTransaction();
  try {
    tx.begin();
    Task managedTask = (Task) pm.getObjectById(Task.class,
        existingTask.getId());
    if (managedTask != null) {
      managedTask.setEmail(existingTask.getEmail());
      managedTask.setTitle(existingTask.getTitle());
      managedTask.setDetails(existingTask.getDetails());
      managedTask.setFinished(existingTask.isFinished());
      managedTask.setLabelPriority(existingTask.getLabelPriority());
      taskId = managedTask.getId();
    }
    tx.commit();
  } catch (Exception e) {
    if (tx.isActive()) {
      tx.rollback();
    }
  } finally {
    pm.close();
  }
  return taskId;
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:27,代码来源:TasksApiImpl.java

示例14: addToExistingOrder

import javax.jdo.Transaction; //导入方法依赖的package包/类
private void addToExistingOrder(List<ITransaction> kioskTransactions,
                                Long orderId, Locale locale)
    throws LogiException {
  IOrder order = orderManagementService.getOrder(orderId, true);
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Transaction tx = null;
  try {
    String message = getAddMaterialsMessage(kioskTransactions, locale);
    tx = pm.currentTransaction();
    tx.begin();
    orderManagementService.modifyOrder(order, Constants.SYSTEM_USER_ID,
        kioskTransactions, new Date(), order.getDomainId(),
        ITransaction.TYPE_REORDER, message, null, null,
        null,
        null, null,
        true, null, order.getReferenceID());
    orderManagementService
        .updateOrder(order, SourceConstants.SYSTEM, true, true, Constants.SYSTEM_USER_ID);
    LOGGER.info("Added new materials to order {0} for kiosk {1} with message {2}", orderId,
        order.getKioskId(), message);
    tx.commit();
  } finally {
    if (tx != null && tx.isActive()) {
      tx.rollback();
    }
    pm.close();
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:29,代码来源:OrderAutomationAction.java

示例15: adjustInventoryEvents

import javax.jdo.Transaction; //导入方法依赖的package包/类
@Override
public IInvntryEvntLog adjustInventoryEvents(IInvntryEvntLog iEvntLog) throws ServiceException {
  PersistenceManager pm = PMF.get().getPersistenceManager();
  Transaction tx = null;
  try {
    tx = pm.currentTransaction();
    tx.begin();
    List<IInvntryEvntLog> logs = invntryDao.removeInvEventLogs(iEvntLog.getKioskId(),
        iEvntLog.getMaterialId(), iEvntLog.getStartDate(), iEvntLog.getEndDate(), pm);
    IInvntry invntry = invntryDao.findId(iEvntLog.getKioskId(), iEvntLog.getMaterialId(), pm);
    iEvntLog.setInvId(invntry.getKey());
    DomainsUtil.addToDomain(iEvntLog, iEvntLog.getDomainId(), pm);
    pm.makePersistent(iEvntLog);
    if (iEvntLog.getKey() == null) {
      pm.makePersistent(iEvntLog);
    }
    for (IInvntryEvntLog log : logs) {
      if (Objects.equals(log.getKey(), invntry.getLastStockEvent())) {
        invntry.setLastStockEvent(iEvntLog.getKey());
        pm.makePersistent(invntry);
        break;
      }
    }
    tx.commit();
  } catch (Exception e) {
    xLogger.severe("Failed to adjust inventory log events for {0}:{1}", iEvntLog.getKioskId(),
        iEvntLog.getDomainId(), e);
    throw new ServiceException(e);
  } finally {
    if (tx != null && tx.isActive()) {
      tx.rollback();
    }
    pm.close();
  }
  return iEvntLog;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:37,代码来源:InventoryManagementServiceImpl.java


注:本文中的javax.jdo.Transaction.isActive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。