throw new ClusterJDatastoreException(local.message("ERR_Datastore_Exception"), e);
}
}
// otherwise, load from the datastore
// TODO: support user-defined oid types
OpenJPAId id = (OpenJPAId)sm.getId();
if (logger.isTraceEnabled()) {
logger.trace("Id: " + id.getClass() + " " + id);
}
// get domain type handler for StateManager
NdbOpenJPADomainTypeHandlerImpl<?> domainTypeHandler = getDomainTypeHandler(sm);
if (!isSupportedType(domainTypeHandler, "NdbOpenJPAStoreManager.initialize")) {
// if not supported, go the jdbc route
boolean result = super.initialize(sm, state, fetch, context);
if (logger.isDebugEnabled()) logger.debug(
"NdbOpenJPAStoreManager.initialize delegated to super: returned " + result);
return result;
}
try {
// get session from session factory
getSession();
session.startAutoTransaction();
// get domain type handler for StateManager
// NdbOpenJPADomainTypeHandlerImpl<?> domainTypeHandler =
// getDomainTypeHandler(sm);
// Object instance = session.initializeFromDatabase(
// domainTypeHandler, null,
// domainTypeHandler.getValueHandler(sm),
// domainTypeHandler.createKeyValueHandler(id.getIdObject()));
// initialize via OpenJPA protocol
// select all columns from table
ValueHandler keyValueHandler = domainTypeHandler.createKeyValueHandler(id.getIdObject());
ResultData resultData = session.selectUnique(domainTypeHandler,
keyValueHandler,
null);
// create an OpenJPA Result from the ndb result data
NdbOpenJPAResult result = new NdbOpenJPAResult(resultData, domainTypeHandler, null);