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


Java Transaction.commit方法代码示例

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


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

示例1: doCommit

import javax.jdo.Transaction; //导入方法依赖的package包/类
@Override
protected void doCommit(DefaultTransactionStatus status) {
	JdoTransactionObject txObject = (JdoTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Committing JDO transaction on PersistenceManager [" +
				txObject.getPersistenceManagerHolder().getPersistenceManager() + "]");
	}
	try {
		Transaction tx = txObject.getPersistenceManagerHolder().getPersistenceManager().currentTransaction();
		tx.commit();
	}
	catch (JDOException ex) {
		// Assumably failed to flush changes to database.
		throw convertJdoAccessException(ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:JdoTransactionManager.java

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

示例3: updateChannelProgramVersion

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Update Channel Program Version.
   * Updates the given Channel's Program Version by 1 in the datastore.
   * @param channelKey
   * 			: the key of the Channel whose attributes will be updated
   */
public static void updateChannelProgramVersion(Key channelKey) {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Channel channel = pm.getObjectById(Channel.class, channelKey);
		tx.begin();
		channel.updateProgramVersion();
		tx.commit();
		log.info("Channel \"" + channel.getChannelName() + 
				"\"'s Program version updated in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:27,代码来源:ChannelManager.java

示例4: updateAdministratorPassword

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Update Administrator password in datastore.
   * Update's the administrator's password in the datastore.
   * @param email
   * 			: the email of the administrator whose password will be changed
   * @param newPassword
   * 			: the new password for this administrator
* @throws MissingRequiredFieldsException
   */
public static void updateAdministratorPassword(Email email, String newPassword) 
		throws MissingRequiredFieldsException {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Key key = KeyFactory.createKey(Administrator.class.getSimpleName(), email.getEmail());
		Administrator administrator = pm.getObjectById(Administrator.class, key);
		tx.begin();
		administrator.getUser().setUserPassword(newPassword);
		tx.commit();
		log.info("Administrator \"" + email.getEmail() + "\"'s password updated in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:31,代码来源:AdministratorManager.java

示例5: updateUserGroupAttributes

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Update UserGroup attributes.
   * Update's the given userGroup's attributes in the datastore.
   * @param userGroupKey
   * 			: the key of the userGroup whose attributes will be updated
   * @param userGroupName
   * 			: the new name to give to the userGroup
   * @param userGroupDescription
   * 			: the description to give to the userGRoup
* @throws MissingRequiredFieldsException 
   */
public static void updateUserGroupAttributes(Key userGroupKey,
		String userGroupName, String userGroupDescription) 
		throws MissingRequiredFieldsException {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		UserGroup userGroup = pm.getObjectById(UserGroup.class, userGroupKey);
		tx.begin();
		userGroup.setUserGroupName(userGroupName);
		userGroup.setUserGroupDescription(userGroupDescription);
		tx.commit();
		log.info("UserGroup \"" + userGroup.getUserGroupName() + 
				"\"'s attributes updated in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:35,代码来源:UserGroupManager.java

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

示例7: updateStationTypeVersion

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
 * Updates the station type version by 1.
 * @param key
 * 			: the key of the station type whose version will be updated
 */
public static void updateStationTypeVersion(Long key) {
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		StationType stationType = pm.getObjectById(StationType.class, key);
		tx.begin();
		stationType.updateStationTypeVersion();
		tx.commit();
		log.info("StationType \"" + stationType.getStationTypeName() + 
                    "\"'s version updated in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:25,代码来源:StationTypeManager.java

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

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

示例10: getOrCreateNewAuthor

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
 * Looks in the data store for an author with a matching email. If the
 * author does not exist, a new one will be created. The newly created
 * author will also have access to a newly created surface.
 *
 * @param user
 *          the user for which an author object is needed
 * @return an author object
 */
public Author getOrCreateNewAuthor(User user) {
  try {
    return getAuthor(user.getEmail());
  } catch (JDOObjectNotFoundException e) {

    final Transaction txA = begin();
    final Surface surface = new Surface("My First Surface");
    surface.addAuthorName(user.getNickname());
    saveSurface(surface);
    txA.commit();

    final Transaction txB = begin();
    final Author author = new Author(user.getEmail(), user.getNickname());
    author.addSurface(surface);
    saveAuthor(author);
    txB.commit();
    return author;
  }
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:29,代码来源:Store.java

示例11: changeNoteContent

import javax.jdo.Transaction; //导入方法依赖的package包/类
public Date changeNoteContent(final String noteKey, final String content)
    throws AccessDeniedException {
  final User user = tryGetCurrentUser(UserServiceFactory.getUserService());
  final Store.Api api = store.getApi();
  try {
    final Key key = KeyFactory.stringToKey(noteKey);
    final Store.Author me = api.getOrCreateNewAuthor(user);

    final Transaction tx = api.begin();
    final Store.Note note = api.getNote(key);
    if (!note.isOwnedBy(me)) {
      throw new Service.AccessDeniedException();
    }
    note.setContent(content);
    final Date result = api.saveNote(note).getLastUpdatedAt();
    tx.commit();

    cache.deleteNotes(getSurfaceKey(note));
    return result;
  } finally {
    api.close();
  }
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:24,代码来源:ServiceImpl.java

示例12: createSurface

import javax.jdo.Transaction; //导入方法依赖的package包/类
public CreateObjectResult createSurface(final String title)
    throws AccessDeniedException {
  final User user = tryGetCurrentUser(UserServiceFactory.getUserService());
  final Store.Api api = store.getApi();
  try {
    final Store.Author me = api.getOrCreateNewAuthor(user);

    final Store.Surface surface = new Store.Surface(title);
    surface.addAuthorName(me.getName());
    api.saveSurface(surface);

    final Transaction tx = api.begin();
    me.addSurface(surface);
    api.saveAuthor(me);
    tx.commit();

    cache.deleteSurfaceKeys(me.getEmail());

    return new CreateObjectResult(KeyFactory.keyToString(surface.getKey()),
        surface.getLastUpdatedAt());
  } finally {
    api.close();
  }
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:25,代码来源:ServiceImpl.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.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。