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


Java Transaction类代码示例

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


Transaction类属于javax.jdo包,在下文中一共展示了Transaction类的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: 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


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