本文整理匯總了Java中javax.jdo.PersistenceManager.detachCopy方法的典型用法代碼示例。如果您正苦於以下問題:Java PersistenceManager.detachCopy方法的具體用法?Java PersistenceManager.detachCopy怎麽用?Java PersistenceManager.detachCopy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jdo.PersistenceManager
的用法示例。
在下文中一共展示了PersistenceManager.detachCopy方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getInvntryEvntLog
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
public IInvntryEvntLog getInvntryEvntLog(IInvntry iInvntry) {
Invntry invntry = (Invntry) iInvntry;
if (invntry.getLastStockEvent() != null) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
IInvntryEvntLog
invLog =
pm.getObjectById(InvntryEvntLog.class, invntry.getLastStockEvent());
invLog = pm.detachCopy(invLog);
return invLog;
} catch (Exception e) {
return null;
} finally {
pm.close();
}
}
return null;
}
示例2: getConfiguration
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
/**
* Get domain-specific configurtion, if domain is specified
*/
public IConfig getConfiguration(String key, Long domainId)
throws ObjectNotFoundException, ServiceException {
if (key == null || key.isEmpty()) {
throw new ServiceException("Invalid key: " + key);
}
IConfig config = null;
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
String realKey = getRealKey(key, domainId);
config = JDOUtils.getObjectById(IConfig.class, realKey, pm);
config = pm.detachCopy(config);
} catch (JDOObjectNotFoundException e) {
xLogger.warn("Config object not found for key: {0}", key);
throw new ObjectNotFoundException(e);
} finally {
pm.close();
}
return config;
}
示例3: addEditMessage
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
public IMessage addEditMessage(IMessage message, boolean isCreate) throws ServiceException {
PersistenceManager pm = null;
try {
pm = PMF.get().getPersistenceManager();
pm.makePersistent(message);
message = pm.detachCopy(message);
} catch (Exception e) {
xLogger.severe("{0} while creating message {1}", e.getMessage(), message, e);
throw new ServiceException(e);
} finally {
if (pm != null) {
pm.close();
}
}
return message;
}
示例4: getEventObject
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
private Object getEventObject() {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
// Get the object associated with the event
if (oId != null) {
Object o = pm.getObjectById(Class.forName(oty), oId);
return pm.detachCopy(o);
}
} catch (Exception e) {
xLogger.warn("{0} when getting object {3} in domain {4}: {5} for event {1}:{2}",
e.getClass().getName(), oty, id, oId, dId, e.getMessage());
} finally {
pm.close();
}
return null;
}
示例5: findInvBatch
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
public IInvntryBatch findInvBatch(Long kioskId, Long materialId, String batchId,
PersistenceManager pm) {
if (batchId == null) {
throw new IllegalArgumentException("Batch Id cannot be null");
}
Query
q =
pm.newQuery("SELECT FROM " + JDOUtils.getImplClassName(IInvntryBatch.class)
+ " WHERE kId == kIdParam && " +
"mId == mIdParam && bid == bIdParam PARAMETERS Long kIdParam, Long mIdParam, String bIdParam");
Map<String, Object> params = new HashMap<>();
params.put("kIdParam", kioskId);
params.put("mIdParam", materialId);
params.put("bIdParam", batchId.toUpperCase());
try {
q.setUnique(true);
IInvntryBatch result = (IInvntryBatch) q.executeWithMap(params);
return pm.detachCopy(result);
} finally {
if (q != null) {
q.closeAll();
}
}
}
示例6: getKioskLink
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
/**
* Get kiosk-link, given the linkid
*/
@Override
public IKioskLink getKioskLink(Long kioskId, String linkType, Long linkedKioskId)
throws ServiceException, ObjectNotFoundException {
xLogger.fine("Entered getKioskLink");
PersistenceManager pm = PMF.get().getPersistenceManager();
IKioskLink kl = null;
String msg = null;
try {
kl =
JDOUtils.getObjectById(IKioskLink.class,
JDOUtils.createKioskLinkId(kioskId, linkType, linkedKioskId), pm);
kl = pm.detachCopy(kl);
} catch (JDOObjectNotFoundException e) {
msg = e.getMessage();
} finally {
pm.close();
}
if (msg != null) {
throw new ObjectNotFoundException(msg);
}
xLogger.fine("Exiting getKioskLink");
return kl;
}
示例7: getUserDevice
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
@Override
public IUserDevice getUserDevice(String userid, String appname) throws ServiceException {
IUserDevice userDevice = null;
PersistenceManager pm = null;
try {
pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(JDOUtils.getImplClass(IUserDevice.class));
query.setFilter("userId == userIdParam && appname == appnameParam");
query.declareParameters("String userIdParam, String appnameParam");
//Query query = pm.newQuery("javax.jdo.query.SQL",q);
query.setUnique(true);
userDevice = (IUserDevice) query.execute(userid, appname);
userDevice = pm.detachCopy(userDevice);
return userDevice;
} catch (Exception e) {
xLogger.severe("{0} while getting user device {1}", e.getMessage(), userid, e);
throw new ServiceException("Issue with getting user device for user :" + userid);
} finally {
if (pm != null) {
pm.close();
}
}
}
示例8: getConversationById
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
public IConversation getConversationById(String convId) throws ServiceException {
IConversation conversation = null;
PersistenceManager pm = null;
try {
pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(JDOUtils.getImplClass(IConversation.class));
query.setFilter("id == :convIdParam");
Map<String, String> paramValues = new HashMap<>(1);
paramValues.put("convIdParam", convId);
query.setUnique(true);
conversation = (IConversation) query.executeWithMap(paramValues);
conversation = pm.detachCopy(conversation);
} catch (Exception e) {
xLogger.severe("{0} while creating getting conversation {1}", e.getMessage(), convId, e);
throw new ServiceException(e);
} finally {
if (pm != null) {
pm.close();
}
}
return conversation;
}
示例9: addEditConversation
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
public IConversation addEditConversation(IConversation conversation, boolean isCreate,
PersistenceManager pm) throws ServiceException {
Set<IConversationTag> ctags = null;
try {
if (null != conversation.getTags() && !conversation.getTags().isEmpty()) {
ctags = constructConversationTags(conversation.getTags(), conversation);
conversation.setConversationTags(ctags);
}
pm.makePersistent(conversation);
conversation = pm.detachCopy(conversation);
} catch (Exception e) {
xLogger.severe("{0} while creating conversation {1}", e.getMessage(), conversation, e);
throw new ServiceException(e);
}
return conversation;
}
示例10: getUploadedByJobId
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public IUploaded getUploadedByJobId(String mrJobId) throws ServiceException {
xLogger.fine("Entered getUploadedByJobId");
PersistenceManager pm = PMF.get().getPersistenceManager();
// Form and execute query
Query
q =
pm.newQuery("SELECT FROM " + JDOUtils.getImplClass(IUploaded.class).getName()
+ " WHERE jid == jidParam PARAMETERS String jidParam");
IUploaded u = null;
try {
List<IUploaded> list = (List<IUploaded>) q.execute(mrJobId);
if (list != null && !list.isEmpty()) {
u = list.get(0);
u = pm.detachCopy(u);
}
} finally {
try {
q.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
pm.close();
}
xLogger.fine("Exiting getUploadedByJobId");
return u;
}
示例11: getDomainByName
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
@Override
public IDomain getDomainByName(String domainName) throws ServiceException {
if (domainName == null || domainName.isEmpty()) {
throw new ServiceException("Invalid parameters");
}
IDomain d = null;
// Form query
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
// Form the query
Query domainQuery = pm.newQuery(JDOUtils.getImplClass(IDomain.class));
domainQuery.setFilter(" nNm == nameParam");
domainQuery.declareParameters("String nameParam");
// Execute the query
try {
List<IDomain> results = (List<IDomain>) domainQuery.execute(domainName.toLowerCase());
if (results != null && !results.isEmpty()) {
d = results.get(0);
d = pm.detachCopy(d);
}
} finally {
domainQuery.closeAll();
}
} catch (Exception e) {
xLogger.severe("{0} when trying to get Domain for Domain Name {1}. Message: {2}",
e.getClass().getName(),
domainName, e);
} finally {
pm.close();
}
return d;
}
示例12: getEvent
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
/**
* Get an event, given its key
*/
public static IEvent getEvent(Long eventKey) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
IEvent event = JDOUtils.getObjectById(IEvent.class, eventKey, pm);
event = pm.detachCopy(event);
return event;
} catch (JDOObjectNotFoundException e) {
return null;
} finally {
pm.close();
}
}
示例13: getTagByName
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
@Override
public ITag getTagByName(String name, int type) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(Tag.class);
query.setFilter("name == nameParam && type == typeParam");
query.declareParameters("String nameParam,Integer typeParam");
ITag result = null;
try {
List<ITag> results = (List<ITag>) query.execute(name, type);
if (results != null && results.size() > 0) {
result = results.get(0);
result = pm.detachCopy(result);
} else {
ITag tag = new Tag(type, name);
tag = pm.makePersistent(tag);
return pm.detachCopy(tag);
}
} catch (Exception e) {
xLogger.warn("Error while fetching tag with name {0} and type {1}", name, type, e);
} finally {
try {
query.closeAll();
} catch (Exception ignored) {
xLogger.warn("Exception while closing query", ignored);
}
pm.close();
}
return result;
}
示例14: getInventory
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
public IInvntry getInventory(Long kioskId, Long materialId) throws ServiceException {
if (kioskId == null || materialId == null) {
throw new IllegalArgumentException("Invalid kiosk ID or material ID");
}
IInvntry inv = null;
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
inv = getInventory(kioskId, materialId, pm);
inv = pm.detachCopy(inv);
} finally {
pm.close();
}
return inv;
}
示例15: getShipmentById
import javax.jdo.PersistenceManager; //導入方法依賴的package包/類
private IShipment getShipmentById(String shipmentId) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
IShipment shipment = getShipmentById(shipmentId, false, pm);
return pm.detachCopy(shipment);
} finally {
pm.close();
}
}