當前位置: 首頁>>代碼示例>>Java>>正文


Java JDOHelper.getPersistenceManager方法代碼示例

本文整理匯總了Java中javax.jdo.JDOHelper.getPersistenceManager方法的典型用法代碼示例。如果您正苦於以下問題:Java JDOHelper.getPersistenceManager方法的具體用法?Java JDOHelper.getPersistenceManager怎麽用?Java JDOHelper.getPersistenceManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jdo.JDOHelper的用法示例。


在下文中一共展示了JDOHelper.getPersistenceManager方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: save

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
public Calendar save(Calendar calendar) {
    PersistenceManager pm;

    if (calendar.getKey() == null) {
        pm = PMF.get().getPersistenceManager();
    } else {
        pm = JDOHelper.getPersistenceManager(calendar);
    }

    try {
        pm.makePersistent(calendar);
    } finally {
        pm.close();
    }

    return calendar;
}
 
開發者ID:masters-info-nantes,項目名稱:myLazyClock,代碼行數:18,代碼來源:CalendarRepository.java

示例2: save

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
public AlarmClock save(AlarmClock alarmClock) {

        PersistenceManager pm = null;

        if (alarmClock.getId() == null) {
            pm = PMF.get().getPersistenceManager();
        }
        else {
            pm = JDOHelper.getPersistenceManager(alarmClock);
        }

        try {
            pm.makePersistent(alarmClock);
        } finally {
            pm.close();
        }

        return alarmClock;
    }
 
開發者ID:masters-info-nantes,項目名稱:myLazyClock,代碼行數:20,代碼來源:AlarmClockRepository.java

示例3: assertUniqueRepoFile

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
/**
 * Asserts that there is only one single {@code CryptoRepoFile} referencing a certain {@link #getRepoFile() RepoFile}.
 * <p>
 * A unique constraint does not work, because multiple {@code CryptoRepoFile}s can have a <code>null</code> reference.
 * Thus we must move this consistency check one layer up - here.
 */
private void assertUniqueRepoFile() {
	if (repoFile == null)
		return;

	final PersistenceManager pm = JDOHelper.getPersistenceManager(this);
	assertNotNull(pm, "JDOHelper.getPersistenceManager(this)");
	final javax.jdo.Query q = pm.newNamedQuery(CryptoRepoFile.class, "getCryptoRepoFile_repoFile");
	final CryptoRepoFile other = (CryptoRepoFile) q.execute(repoFile);
	if (other != null && !this.equals(other))
		throw new IllegalStateException(String.format(
				"Constraint violation: There is already another CryptoRepoFile (id=%s) referencing the same RepoFile (id=%s)!",
				other.getId(), repoFile.getId()));
}
 
開發者ID:subshare,項目名稱:subshare,代碼行數:20,代碼來源:CryptoRepoFile.java

示例4: jdoPreStore

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
@Override
public void jdoPreStore() {
	final Uid collisionId = getCollisionId();
	final CryptoRepoFile cryptoRepoFile1 = assertNotNull(histoCryptoRepoFile1, "histoCryptoRepoFile1").getCryptoRepoFile();
	final CryptoRepoFile cryptoRepoFile2 = histoCryptoRepoFile2 == null ? null : histoCryptoRepoFile2.getCryptoRepoFile();
	final CryptoRepoFile parent1 = assertNotNull(cryptoRepoFile1, "cryptoRepoFile1").getParent();
	final CryptoRepoFile parent2 = cryptoRepoFile2 == null ? null : cryptoRepoFile2.getParent();

	if (histoCryptoRepoFile2 == null && duplicateCryptoRepoFileId == null)
		throw new IllegalStateException("Both histoCryptoRepoFile2 and duplicateCryptoRepoFileId are null! One of them must be non-null!");

	if (histoCryptoRepoFile2 != null && duplicateCryptoRepoFileId != null)
		throw new IllegalStateException("Both histoCryptoRepoFile2 and duplicateCryptoRepoFileId are non-null! One of them must be null!");

	if (histoCryptoRepoFile2 != null && cryptoRepoFile2 == null)
		throw new IllegalStateException("histoCryptoRepoFile2 is not null, but cryptoRepoFile2 is null!");

	if (duplicateCryptoRepoFileId == null && ! equal(parent1, parent2))
		throw new IllegalStateException(String.format(
				"histoCryptoRepoFile1.cryptoRepoFile.parent != histoCryptoRepoFile2.cryptoRepoFile.parent :: histoCryptoRepoFile1=%s histoCryptoRepoFile2=%s parent1=%s parent2=%s",
				histoCryptoRepoFile1, histoCryptoRepoFile2, parent1, parent2));

	if (! collisionId.equals(calculateCollisionId()))
		throw new IllegalStateException("collisionId != calculateCollisionId()");

	final PersistenceManager pm = JDOHelper.getPersistenceManager(this);
	final CollisionDao collisionDao = new CollisionDao().persistenceManager(pm);
	Collision c = collisionDao.getCollision(histoCryptoRepoFile1, histoCryptoRepoFile2, getDuplicateCryptoRepoFileId());
	if (c != null && c != this)
		throw new IllegalStateException(String.format("There is already another Collision between these two HistoCryptoRepoFiles/duplicateCryptoRepoFileId: %s, %s, %s",
				histoCryptoRepoFile1, histoCryptoRepoFile2, duplicateCryptoRepoFileId));
}
 
開發者ID:subshare,項目名稱:subshare,代碼行數:33,代碼來源:Collision.java

示例5: delete

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
public void delete(Calendar calendar) {
    PersistenceManager pm = JDOHelper.getPersistenceManager(calendar);

    try {
        pm.deletePersistent(calendar);
    } finally {
        pm.close();
    }
}
 
開發者ID:masters-info-nantes,項目名稱:myLazyClock,代碼行數:10,代碼來源:CalendarRepository.java


注:本文中的javax.jdo.JDOHelper.getPersistenceManager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。