本文整理汇总了Java中javax.jdo.JDOObjectNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java JDOObjectNotFoundException类的具体用法?Java JDOObjectNotFoundException怎么用?Java JDOObjectNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JDOObjectNotFoundException类属于javax.jdo包,在下文中一共展示了JDOObjectNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMaterial
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
public IMaterial getMaterial(Long materialId) throws ServiceException {
xLogger.fine("Entering getMaterial");
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
//Get the material object from the database
IMaterial material = JDOUtils.getObjectById(IMaterial.class, materialId, pm);
//If we get here, it means the material exists
material = pm.detachCopy(material);
xLogger.fine("Exiting getMaterial");
return material;
} catch (JDOObjectNotFoundException e) {
xLogger.warn("getMaterial: FAILED!!! Material {0} does not exist in the database", materialId,
e);
throw new ServiceException(
messages.getString("material") + " " + materialId + " " + backendMessages
.getString("error.notfound"));
} finally {
pm.close();
}
}
示例2: getHandlingUnit
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
@Override
public IHandlingUnit getHandlingUnit(Long handlingUnitId) throws ServiceException {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
IHandlingUnit material = JDOUtils.getObjectById(IHandlingUnit.class, handlingUnitId, pm);
material = pm.detachCopy(material);
return material;
} catch (JDOObjectNotFoundException e) {
xLogger.warn("get handling unit: FAILED!!! Handling unit {0} does not exist in the database",
handlingUnitId, e);
throw new ServiceException(
"Handling unit " + handlingUnitId + " " + backendMessages.getString("error.notfound"));
} finally {
pm.close();
}
}
示例3: getKioskLink
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
/**
* Get a given kiosk link
*/
public IKioskLink getKioskLink(String linkId) throws ObjectNotFoundException, ServiceException {
xLogger.fine("Entered getKioskLink");
IKioskLink link = null;
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
link = JDOUtils.getObjectById(IKioskLink.class, linkId, pm);
link = pm.detachCopy(link);
} catch (JDOObjectNotFoundException e) {
throw new ObjectNotFoundException(e.getMessage());
} finally {
pm.close();
}
xLogger.fine("Exiting getKioskLink");
return link;
}
示例4: getConfiguration
import javax.jdo.JDOObjectNotFoundException; //导入依赖的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;
}
示例5: getLog
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
public static IMessageLog getLog(String jobId, String address) throws MessageHandlingException {
if (jobId == null && address == null) {
throw new MessageHandlingException("Invalid input parameters when getting message log");
}
IMessageLog mlog = null;
PersistenceManager pm = PMF.get().getPersistenceManager();
String msg = null;
try {
String key = JDOUtils.createMessageLogKey(jobId, address);
mlog = JDOUtils.getObjectById(IMessageLog.class, key, pm);
mlog = pm.detachCopy(mlog);
} catch (JDOObjectNotFoundException e) {
msg =
"Message log with key '" + JDOUtils.createMessageLogKey(jobId, address) + "' not found ["
+ e.getMessage() + "]";
} finally {
pm.close();
}
if (msg != null) {
throw new MessageHandlingException(msg);
}
return mlog;
}
示例6: removeMultipartMsg
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
public static void removeMultipartMsg(String id) throws MessageHandlingException {
if (id == null || id.isEmpty()) {
throw new MessageHandlingException("Invalid ID");
}
PersistenceManager pm = PMF.get().getPersistenceManager();
String err = null;
try {
IMultipartMsg mmsg = JDOUtils.getObjectById(IMultipartMsg.class, id, pm);
removeMultipartMsg(mmsg);
} catch (JDOObjectNotFoundException e) {
err = e.getMessage();
} finally {
pm.close();
}
if (err != null) {
throw new MessageHandlingException(err);
}
}
示例7: updateUploaded
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
public void updateUploaded(IUploaded u) throws ServiceException, ObjectNotFoundException {
if (u == null) {
throw new ServiceException("Nothing to update");
}
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
IUploaded uploaded = JDOUtils.getObjectById(IUploaded.class, u.getId(), pm);
uploaded.setBlobKey(u.getBlobKey());
uploaded.setDescription(u.getDescription());
uploaded.setDomainId(u.getDomainId());
uploaded.setFileName(u.getFileName());
uploaded.setLocale(u.getLocale());
uploaded.setTimeStamp(u.getTimeStamp());
uploaded.setType(u.getType());
uploaded.setUserId(u.getUserId());
uploaded.setVersion(u.getVersion());
uploaded.setJobId(u.getJobId());
uploaded.setJobStatus(u.getJobStatus());
} catch (JDOObjectNotFoundException e) {
throw new ObjectNotFoundException(e.getMessage());
} finally {
pm.close();
}
}
示例8: convertJdoAccessException
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
/**
* Convert the given JDOException to an appropriate exception from the
* {@code org.springframework.dao} hierarchy.
* <p>The most important cases like object not found or optimistic locking failure
* are covered here. For more fine-granular conversion, JdoTransactionManager
* supports sophisticated translation of exceptions via a JdoDialect.
* @param ex JDOException that occured
* @return the corresponding DataAccessException instance
* @see JdoTransactionManager#convertJdoAccessException
* @see JdoDialect#translateException
*/
public static DataAccessException convertJdoAccessException(JDOException ex) {
if (ex instanceof JDOObjectNotFoundException) {
throw new JdoObjectRetrievalFailureException((JDOObjectNotFoundException) ex);
}
if (ex instanceof JDOOptimisticVerificationException) {
throw new JdoOptimisticLockingFailureException((JDOOptimisticVerificationException) ex);
}
if (ex instanceof JDODataStoreException) {
return new JdoResourceFailureException((JDODataStoreException) ex);
}
if (ex instanceof JDOFatalDataStoreException) {
return new JdoResourceFailureException((JDOFatalDataStoreException) ex);
}
if (ex instanceof JDOUserException) {
return new JdoUsageException((JDOUserException) ex);
}
if (ex instanceof JDOFatalUserException) {
return new JdoUsageException((JDOFatalUserException) ex);
}
// fallback
return new JdoSystemException(ex);
}
示例9: getCustomer
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
/**
* Get a Customer instance from the datastore given the user's email.
* The method uses this email to obtain the Customer key.
* @param email
* : the customer's email address
* @return customer instance, null if customer is not found
*/
public static Customer getCustomer(Email email) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Key key = KeyFactory.createKey(Customer.class.getSimpleName(),
email.getEmail());
Customer customer;
try {
customer = pm.getObjectById(Customer.class, key);
}
catch (JDOObjectNotFoundException e) {
return null;
}
pm.close();
return customer;
}
示例10: getStation
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
/**
* Get a Station instance from the datastore given the user's email.
* The method uses this email to obtain the Station key.
* @param email
* : the Station's email address
* @return Station instance, null if Station is not found
*/
public static Station getStation(Email email) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Key key = KeyFactory.createKey(Station.class.getSimpleName(),
email.getEmail());
Station station;
try {
station = pm.getObjectById(Station.class, key);
}
catch (JDOObjectNotFoundException e) {
return null;
}
pm.close();
return station;
}
示例11: getAdministrator
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
/**
* Get a Administrator instance from the datastore given the user's email.
* The method uses this email to obtain the Administrator key.
* @param email
* : the administrator's email address
* @return administrator instance, null if administrator is not found
*/
public static Administrator getAdministrator(Email email) {
PersistenceManager pm = PMF.get().getPersistenceManager();
Key key = KeyFactory.createKey(Administrator.class.getSimpleName(),
email.getEmail());
Administrator administrator;
try {
administrator = pm.getObjectById(Administrator.class, key);
}
catch (JDOObjectNotFoundException e) {
return null;
}
pm.close();
return administrator;
}
示例12: findBySanitizedTitle
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
public Article findBySanitizedTitle(String sanitizedTitle) {
Article article = null;
try {
Query query = pm.newQuery(Article.class);
query.setFilter("sanitizedTitle == sanitizedTitleParam");
query.declareParameters("String sanitizedTitleParam");
List<Article> articles = (List<Article>) query
.execute(sanitizedTitle);
if (articles.size() == 1) {
article = articles.get(0);
}
} catch (JDOObjectNotFoundException e) {
LOGGER.warning(e.getMessage());
}
return article;
}
示例13: findByYearMonth
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
public List<Article> findByYearMonth(int year, int month) {
List<Article> articles = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
Date fromDate = calendar.getTime();
calendar.add(Calendar.MONTH, 1);
Date toDate = calendar.getTime();
try {
Query query = pm.newQuery(Article.class);
query.setFilter("publicationDate >= fromDateParam && publicationDate < toDateParam");
query.declareImports("import java.util.Date");
query.declareParameters("Date fromDateParam, Date toDateParam");
articles = (List<Article>) query.execute(fromDate, toDate);
} catch (JDOObjectNotFoundException e) {
LOGGER.warning(e.getMessage());
}
return articles;
}
示例14: convertJdoAccessException
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
/**
* Convert the given JDOException to an appropriate exception from the
* {@code org.springframework.dao} hierarchy.
* <p>The most important cases like object not found or optimistic locking
* failure are covered here. For more fine-granular conversion, JdoAccessor and
* JdoTransactionManager support sophisticated translation of exceptions via a
* JdoDialect.
* @param ex JDOException that occured
* @return the corresponding DataAccessException instance
* @see JdoAccessor#convertJdoAccessException
* @see JdoTransactionManager#convertJdoAccessException
* @see JdoDialect#translateException
*/
public static DataAccessException convertJdoAccessException(JDOException ex) {
if (ex instanceof JDOObjectNotFoundException) {
throw new JdoObjectRetrievalFailureException((JDOObjectNotFoundException) ex);
}
if (ex instanceof JDOOptimisticVerificationException) {
throw new JdoOptimisticLockingFailureException((JDOOptimisticVerificationException) ex);
}
if (ex instanceof JDODataStoreException) {
return new JdoResourceFailureException((JDODataStoreException) ex);
}
if (ex instanceof JDOFatalDataStoreException) {
return new JdoResourceFailureException((JDOFatalDataStoreException) ex);
}
if (ex instanceof JDOUserException) {
return new JdoUsageException((JDOUserException) ex);
}
if (ex instanceof JDOFatalUserException) {
return new JdoUsageException((JDOFatalUserException) ex);
}
// fallback
return new JdoSystemException(ex);
}
示例15: getBlog
import javax.jdo.JDOObjectNotFoundException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Blog getBlog()
{
if( blog != null ) return blog;
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
Query q = pm.newQuery( Blog.class );
q.setFilter("userId == :userId");
q.setRange(0, 1);
List<Blog> blogs = (List<Blog>)q.execute(getId());
if( blogs.isEmpty() ) return null;
blog = blogs.get(0);
return blog;
} catch( JDOObjectNotFoundException e ) {
return null;
} finally {
pm.close();
}
}