• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Transaction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Transaction类属于javax.jdo包,在下文中一共展示了Transaction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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


示例3: alterUser

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

        MUser mUser = (MUser) getUser(name);
        mUser.setPassword(newPassword);
        pm.makePersistent(mUser);

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


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


示例5: commentOnUser

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

        MUser mUser = (MUser) getUser(name);
        mUser.setComment(comment);
        pm.makePersistent(mUser);

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


示例6: dropJdbcDataSource

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

        pm.deletePersistent(getDataSource(name));

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


示例7: addSystemPrivileges

import javax.jdo.Transaction; //导入依赖的package包/类
@Override
public void addSystemPrivileges(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.addSystemPrivilege(sysPriv);

            pm.makePersistent(mUser);
        }

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


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


示例9: delTbl

import javax.jdo.Transaction; //导入依赖的package包/类
public void delTbl(String dbName, String tblName) {
  TableMeta tblMeta = getTbl(dbName, tblName);

  if(tblMeta == null)
    return;

  List<ColumnMeta> columnMetas = tblMeta.getCols();

  Transaction tx = pm.currentTransaction();
  try {
    tx.begin();
    for(ColumnMeta columnMeta : columnMetas) {
      pm.deletePersistent(columnMeta);
    }

    pm.deletePersistent(tblMeta);
    tx.commit();
  } finally {
    if (tx.isActive()) {
      tx.rollback();
    }
  }

}
 
开发者ID:andyhehk,项目名称:SecureDB,代码行数:25,代码来源:MetaStore.java


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


示例11: updateCustomerPassword

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


示例12: updateCustomerStatus

import javax.jdo.Transaction; //导入依赖的package包/类
/**
   * Update Customer status in datastore.
   * Update's the customer's status in the datastore.
   * @param email
   * 			: the email of the customer whose status will be changed
   * @param status
   * 			: the status to be assigned to this customer
* @throws MissingRequiredFieldsException
   */
public static void updateCustomerStatus(Email email, Customer.Status status) 
		throws MissingRequiredFieldsException {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Key key = KeyFactory.createKey(Customer.class.getSimpleName(), email.getEmail());
		Customer customer = pm.getObjectById(Customer.class, key);
		tx.begin();
		customer.setCustomerStatus(status);
		tx.commit();
		log.info("Customer \"" + email.getEmail() + "\"'s status updated in datastore.");
		
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:32,代码来源:CustomerManager.java


示例13: updateCustomerCloudSyncCommand

import javax.jdo.Transaction; //导入依赖的package包/类
/**
   * Update Customer cloud sync command.
   * Update's the given customer's cloud sync command in the datastore.
   * @param email
   * 			: the email of the customer whose attributes will be updated
   * @param cloudSyncCommand
   * 			: the cloud sync message to set
   */
public static void updateCustomerCloudSyncCommand(Email email, 
		CloudSyncCommand cloudSyncCommand)  {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		Key key = KeyFactory.createKey(Customer.class.getSimpleName(), 
				email.getEmail());
		Customer customer = pm.getObjectById(Customer.class, key);
		CloudSyncCommand previousCloudSyncCommand = customer.getCloudSyncCommand();
		tx.begin();
		pm.deletePersistent(previousCloudSyncCommand);
		customer.setCloudSyncCommand(cloudSyncCommand);
		tx.commit();
		log.info("Customer \"" + email.getEmail() + 
				"\"'s cloud sync command updated.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:34,代码来源:CustomerManager.java


示例14: putStationType

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


示例15: deleteStationType

import javax.jdo.Transaction; //导入依赖的package包/类
/**
   * Delete StationType from datastore.
   * Deletes the StationType corresponding to the given key
   * from the datastore calling the PersistenceManager's 
   * deletePersistent() method.
   * @param key
   * 			: the key of the StationType instance to delete
   */
public static void deleteStationType(Long key) {	
	
	PersistenceManager pm = PMF.get().getPersistenceManager();
	
	Transaction tx = pm.currentTransaction();
	try {
		StationType stationType = pm.getObjectById(StationType.class, key);
		String StationTypeName = stationType.getStationTypeName();
		tx.begin();
		pm.deletePersistent(stationType);
		tx.commit();
		log.info("StationType \"" + StationTypeName + 
                    "\" deleted successfully from datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:30,代码来源:StationTypeManager.java


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


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


示例18: putPlaylist

import javax.jdo.Transaction; //导入依赖的package包/类
/**
   * Add playlist to a Station.
   * Add a new playlist in the datastore for this Station.
   * @param email
   * 			: the email of the Station where the playlist will be added
   * @param playlist
   * 			: the playlist to be added
   */
public static void putPlaylist(Email stationEmail, Playlist playlist) {	
	
	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.addPlaylist(playlist);
		tx.commit();
		log.info("Playlist \"" + playlist.getPlaylistName() + "\" added to Station \"" + 
				stationEmail.getEmail() + "\" in datastore.");
	}
	finally {
		if (tx.isActive()) {
			tx.rollback();
		}
		pm.close();
	}
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:31,代码来源:PlaylistManager.java


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WorldGenHellLava类代码示例发布时间:2022-05-21
下一篇:
Java CheckboxPeer类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap