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


Java Transaction.rollback方法代码示例

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


在下文中一共展示了Transaction.rollback方法的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: deleteAdministrator

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Delete Administrator from datastore.
   * Deletes the administrator corresponding to the given email 
   * from the datastore calling the PersistenceManager's deletePersistent() method.
   * @param email
   * 			: the email of the administrator instance to delete
   */
public static void deleteAdministrator(Email email) {	
	
	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();
		pm.deletePersistent(administrator);
		tx.commit();
		log.info("Administrator \"" + email.getEmail() + "\" deleted successfully from datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:28,代码来源:AdministratorManager.java

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

示例5: updateStationTypeAttributes

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

示例6: putUserRecommendation

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
    * Put UserRecommendation into datastore.
    * Stores the given userRecommendation instance for a Customer in the datastore
    * calling the PersistenceManager's makePersistent() method.
    * @param customerKey
    * 			: the key of the customer to which the recommendation belongs
    * @param userRecommendation
    * 			: the userRecommendation instance to store
    */
public static void putUserRecommendation(Key customerKey, 
		UserRecommendation userRecommendation) 
		throws ObjectExistsInDatastoreException {
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Customer customer = pm.getObjectById(Customer.class, customerKey);
		tx.begin();
		customer.addUserRecommendation(userRecommendation);
		tx.commit();
		log.info("UserRecommendation \"" + 
				userRecommendation.getUserRecommendationCreationDate() + 
				"\" stored successfully in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:32,代码来源:UserRecommendationManager.java

示例7: updateStationPlaylistVersion

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

示例8: deleteChannel

import javax.jdo.Transaction; //导入方法依赖的package包/类
/**
   * Delete channel.
   * Delete a channel in the datastore.
   * @param key
   * 			: the key of the channel to delete (includes Station key)
   */
public static void deleteChannel(Key key) {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Station station = pm.getObjectById(Station.class, key.getParent());
		Channel channel = pm.getObjectById(Channel.class, key);
		String channelName = channel.getChannelName();
		tx.begin();
		station.removeChannel(channel);
		tx.commit();
		log.info("Channel \"" + channelName + "\" deleted from Station \"" + 
				station.getUser().getUserEmail().getEmail() + "\" in datastore.");
	} 
	catch (InexistentObjectException e) {
		e.printStackTrace();
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:32,代码来源:ChannelManager.java

示例9: updateStationPassword

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

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

示例11: putGenre

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

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

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

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

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


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