Package com.google.ytd.util

Source Code of com.google.ytd.util.PmfUtil

package com.google.ytd.util;

import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;

import com.google.inject.Inject;

public class PmfUtil {
  private PersistenceManagerFactory pmf = null;

  @Inject
  public PmfUtil(PersistenceManagerFactory pmf) {
    this.pmf = pmf;
  }

  public PersistenceManagerFactory getPmf() {
    return pmf;
  }

  public Object persistJdo(Object entry) {
    PersistenceManager pm = pmf.getPersistenceManager();

    try {
      entry = pm.makePersistent(entry);
      entry = pm.detachCopy(entry);
    } finally {
      pm.close();
    }

    return entry;
  }

  public void removeJdo(Object entry) {
    PersistenceManager pm = pmf.getPersistenceManager();

    try {
      pm.deletePersistent(entry);
    } finally {
      pm.close();
    }
  }
}
TOP

Related Classes of com.google.ytd.util.PmfUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.