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


Java Transaction.begin方法代码示例

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


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

示例1: 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

示例2: putSecondaryTrack

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

示例3: putRegion

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
    * Put Region into datastore.
    * Stores the given region instance in the datastore calling the PersistenceManager's
    * makePersistent() method.
    * @param region
    * 			: the region instance to store
    */
public static void putRegion(Region region) {
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		tx.begin();
		pm.makePersistent(region);
		tx.commit();
		log.info("Region \"" + region.getRegionName() + 
			"\" stored successfully in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:26,代码来源:RegionManager.java

示例4: updateChannelAttributes

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Update Channel attributes.
   * Updates the given Channel's attributes in the datastore.
   * @param key
   * 			: the key of the Channel whose attributes will be updated
   * @param region
   * 			: the key of the region
   * @param channelName
   * 			: the new name to give to the Channel
   * @param channelAddress
   * 			: the new address to give to the Channel
   * @param channelPhone
   * 			: the new phone to give to the Channel
   * @param channelEmail
   * 			: the contact email of this channel
* @throws MissingRequiredFieldsException
* @throws InvalidFieldFormatException
* @throws InvalidFieldSelectionException 
   */
public static void updateChannelAttributes(Key key, String channelName,
		Integer channelNumber)
		throws MissingRequiredFieldsException {
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Channel channel = pm.getObjectById(Channel.class, key);
		tx.begin();
		channel.setChannelName(channelName);
		channel.setChannelNumber(channelNumber);
		tx.commit();
		log.info("Channel \"" + channelName + "\"'s attributes updated in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:42,代码来源:ChannelManager.java

示例5: deleteAdministrator

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Delete Administrator from datastore.
   * Deletes the given administrator from the datastore calling the PersistenceManager's
   * deletePersistent() method.
   * @param administrator
   * 			: the administrator instance to delete
   */
public static void deleteAdministrator(Administrator administrator) {
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		administrator = pm.getObjectById(Administrator.class, administrator.getKey());
		String email = administrator.getUser().getUserEmail().getEmail();
		tx.begin();
		pm.deletePersistent(administrator);
		tx.commit();
		log.info("Administrator \"" + email + "\" deleted successfully from datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:27,代码来源:AdministratorManager.java

示例6: deleteCustomer

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Delete Customer from datastore.
   * Deletes the given customer from the datastore calling the PersistenceManager's
   * deletePersistent() method.
   * @param customer
   * 			: the customer instance to delete
   */
public static void deleteCustomer(Customer customer) {
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		customer = pm.getObjectById(Customer.class, customer.getKey());
		String email = customer.getUser().getUserEmail().getEmail();
		tx.begin();
		pm.deletePersistent(customer);
		tx.commit();
		log.info("Customer \"" + email + "\" deleted successfully from datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:27,代码来源:CustomerManager.java

示例7: 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

示例8: updateGenreAttributes

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Update Genre attributes.
   * Update's the given genre's attributes in the datastore.
   * @param key
   * 			: the key of the genre whose attributes will be updated
   * @param genreEnglishName
   * 			: the English name of the Genre
   * @param genreChineseName
   * 			: the Chinese name of the Genre
* @throws MissingRequiredFieldsException 
   */
public static void updateGenreAttributes(Long key,
		String genreEnglishName, String genreChineseName) 
   				throws MissingRequiredFieldsException {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Genre genre = pm.getObjectById(Genre.class, key);
		tx.begin();
		genre.setGenreEnglishName(genreEnglishName);
		genre.setGenreChineseName(genreChineseName);
		tx.commit();
		log.info("Genre \"" + genreEnglishName + 
				"\"'s attributes updated in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:35,代码来源:GenreManager.java

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: beginTransaction

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
 * This implementation invokes the standard JDO {@link Transaction#begin()}
 * method and also {@link Transaction#setIsolationLevel(String)} if necessary.
 * @see javax.jdo.Transaction#begin
 * @see org.springframework.transaction.InvalidIsolationLevelException
 */
@Override
public Object beginTransaction(Transaction transaction, TransactionDefinition definition)
		throws JDOException, SQLException, TransactionException {

	String jdoIsolationLevel = getJdoIsolationLevel(definition);
	if (jdoIsolationLevel != null) {
		transaction.setIsolationLevel(jdoIsolationLevel);
	}
	transaction.begin();
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:DefaultJdoDialect.java

示例15: persistSparkAccountStatus

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
 * Not sure what this does - adding from SDK boilerplate
 *
 * @param ac
 * @throws Exception
 */
public static void persistSparkAccountStatus(StorageAccountStatus ac) throws Exception {
	PersistenceManager pm = ObjStoreHelper.getPersistenceManager();
	Transaction tx = pm.currentTransaction();

	try {
		tx.begin();

		String query = "accountName == '" + ac.getAccountName() + "'";

		Query q = pm.newQuery(StorageAccountStatus.class, query);
		q.deletePersistentAll();

		pm.makePersistent(ac);
		tx.commit();
	}
	finally {
		try {
			if (tx.isActive()) {
				tx.rollback();
			}
		}
		finally {
			pm.close();
		}
	}
}
 
开发者ID:CiscoUKIDCDev,项目名称:ucsd-spark-plugin,代码行数:33,代码来源:SparkAccountStatusSummary.java


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