本文整理汇总了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;
}
示例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;
}
示例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()));
}
示例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));
}
示例5: delete
import javax.jdo.JDOHelper; //导入方法依赖的package包/类
public void delete(Calendar calendar) {
PersistenceManager pm = JDOHelper.getPersistenceManager(calendar);
try {
pm.deletePersistent(calendar);
} finally {
pm.close();
}
}