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


Java JDOHelper.getObjectId方法代碼示例

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


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

示例1: equals

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
@Override
public boolean equals(final Object obj) {
	if (this == obj) {
		return true;
	}
	if (obj == null) {
		return false;
	}

	final Object thisOid = JDOHelper.getObjectId(this);
	if (thisOid == null) {
		return false;
	}

	final Object otherOid = JDOHelper.getObjectId(obj);
	return thisOid.equals(otherOid);
}
 
開發者ID:cloudstore,項目名稱:cloudstore,代碼行數:18,代碼來源:Entity.java

示例2: hashCode

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
@Override
public int hashCode() {
	if (hashCode == 0) {
		// Freeze the hashCode.
		//
		// We make sure the hashCode does not change after it was once initialised, because the object might
		// have been added to a HashSet (or Map) before being persisted. During persistence, the object's id is
		// assigned and without freezing the hashCode, the object is thus not found in the Map/Set, anymore.
		//
		// This new strategy seems to be working well; messages like this do not occur anymore:
		//
		// Aug 22, 2014 9:44:23 AM org.datanucleus.store.rdbms.mapping.java.PersistableMapping postInsert
		// INFO: Object "[email protected]" has field "co.codewizards.cloudstore.local.persistence.FileChunk.normalFile" with an N-1 bidirectional relation set to relate to "[email protected]" but the collection at "co.codewizards.cloudstore.local.persistence.NormalFile.fileChunks" doesnt contain this object.

		final Object thisOid = JDOHelper.getObjectId(this);
		if (thisOid == null)
			hashCode = super.hashCode();
		else
			hashCode = thisOid.hashCode();

		if (hashCode == 0) // very unlikely, but we want our code to be 100% robust.
			hashCode = 1;
	}
	return hashCode;
}
 
開發者ID:cloudstore,項目名稱:cloudstore,代碼行數:26,代碼來源:Entity.java

示例3: getId

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
@Programmatic
public String getId() {
    Object objectId = JDOHelper.getObjectId(this);
    if (objectId == null) {
        return "";
    }
    String objectIdStr = objectId.toString();
    final String id = objectIdStr.split("\\[OID\\]")[0];
    return id;
}
 
開發者ID:bibryam,項目名稱:semat,代碼行數:11,代碼來源:AbstractPersistable.java

示例4: preDelete

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
@Override
public void preDelete(final InstanceLifecycleEvent event) {
	// We want to ensure that the revision is incremented, even if we do not have any remote repository connected
	// (and thus no DeleteModification being created).
	getTransactionOrFail().getLocalRevision();

	final Object oid = JDOHelper.getObjectId(event.getPersistentInstance());
	oid2LastChanged.remove(oid);
}
 
開發者ID:cloudstore,項目名稱:cloudstore,代碼行數:10,代碼來源:AutoTrackLifecycleListener.java

示例5: JdoObjectRetrievalFailureException

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
public JdoObjectRetrievalFailureException(JDOObjectNotFoundException ex) {
	// Extract information about the failed object from the JDOException, if available.
	super((ex.getFailedObject() != null ? ex.getFailedObject().getClass() : null),
			(ex.getFailedObject() != null ? JDOHelper.getObjectId(ex.getFailedObject()) : null),
			ex.getMessage(), ex);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:7,代碼來源:JdoObjectRetrievalFailureException.java

示例6: JdoOptimisticLockingFailureException

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
public JdoOptimisticLockingFailureException(JDOOptimisticVerificationException ex) {
	// Extract information about the failed object from the JDOException, if available.
	super((ex.getFailedObject() != null ? ex.getFailedObject().getClass() : null),
			(ex.getFailedObject() != null ? JDOHelper.getObjectId(ex.getFailedObject()) : null),
			ex.getMessage(), ex);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:7,代碼來源:JdoOptimisticLockingFailureException.java

示例7: checkSample

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
@Override
	protected void checkSample(File sample) throws Exception {
		// TODO Auto-generated method stub
		final JAXBContext context = createContext();
		logger.debug("Unmarshalling.");
		final Unmarshaller unmarshaller = context.createUnmarshaller();
		// Unmarshall the document
		final JAXBElement element = (JAXBElement) unmarshaller
				.unmarshal(sample);
		final Object object = element.getValue();
		logger.debug("Opening session.");
		// Open the session, save object into the database
		logger.debug("Saving the object.");
		final PersistenceManager saveManager = createPersistenceManager();
//		saveManager.setDetachAllOnCommit(true);
		final Transaction saveTransaction = saveManager.currentTransaction();
		saveTransaction.setNontransactionalRead(true);
		saveTransaction.begin();
		// final Object merged = saveSession.merge(object);
		// saveSession.replicate(object, ReplicationMode.OVERWRITE);
		// saveSession.get
		// final Serializable id =
		final Object mergedObject = saveManager.makePersistent(object);
		
//		final Object asd = saveManager.detachCopy(object);
		saveTransaction.commit();
//		final Object id = saveManager.getObjectId(mergedObject);
		final Object identity = JDOHelper.getObjectId(object);
		final Object id = identity instanceof SingleFieldIdentity ? ((SingleFieldIdentity) identity).getKeyAsObject() : identity;
		// Close the session
		saveManager.close();

		logger.debug("Opening session.");
		// Open the session, load the object
		final PersistenceManager loadManager = createPersistenceManager();
		final Transaction loadTransaction = loadManager.currentTransaction();
		loadTransaction.setNontransactionalRead(true);
		logger.debug("Loading the object.");
		final Object loadedObject = loadManager.getObjectById(mergedObject.getClass(), id);
		logger.debug("Closing the session.");

		final JAXBElement mergedElement = new JAXBElement(element.getName(),
				element.getDeclaredType(), object);

		final JAXBElement loadedElement = new JAXBElement(element.getName(),
				element.getDeclaredType(), loadedObject);

		logger.debug("Checking the document identity.");

		logger.debug("Source object:\n"
				+ ContextUtils.toString(context, mergedElement));
		logger.debug("Result object:\n"
				+ ContextUtils.toString(context, loadedElement));

		checkObjects(mergedObject, loadedObject);
		loadManager.close();

	}
 
開發者ID:highsource,項目名稱:hyperjaxb3,代碼行數:59,代碼來源:RoundtripTest.java

示例8: toString_getProperties

import javax.jdo.JDOHelper; //導入方法依賴的package包/類
protected String toString_getProperties() {
	return "id=" + JDOHelper.getObjectId(this);
}
 
開發者ID:cloudstore,項目名稱:cloudstore,代碼行數:4,代碼來源:Entity.java


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