当前位置: 首页>>代码示例>>Java>>正文


Java ObjectNotFoundException类代码示例

本文整理汇总了Java中org.hibernate.ObjectNotFoundException的典型用法代码示例。如果您正苦于以下问题:Java ObjectNotFoundException类的具体用法?Java ObjectNotFoundException怎么用?Java ObjectNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ObjectNotFoundException类属于org.hibernate包,在下文中一共展示了ObjectNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
@Override
public final Object load() {
	final Serializable entityId = resolveNaturalId( this.naturalIdParameters );
	if ( entityId == null ) {
		return null;
	}
	try {
		return this.getIdentifierLoadAccess().load( entityId );
	}
	catch (EntityNotFoundException enf) {
		// OK
	}
	catch (ObjectNotFoundException nf) {
		// OK
	}
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:SessionImpl.java

示例2: getAssignment

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
public Assignment getAssignment(Class_ clazz) {
      Long solutionId = getSolutionId(clazz);
if (solutionId==null) return super.getAssignment(clazz);
      Iterator i = null;
      try {
          i = clazz.getAssignments().iterator();
      } catch (ObjectNotFoundException e) {
          new _RootDAO().getSession().refresh(clazz);
          i = clazz.getAssignments().iterator();
      }
      while (i.hasNext()) {
	Assignment a = (Assignment)i.next();
	if (solutionId.equals(a.getSolution().getUniqueId())) return a;
}
return null;
  }
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:17,代码来源:SolutionClassAssignmentProxy.java

示例3: testLoadWithNotFound

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
@Test
public void testLoadWithNotFound() throws HibernateException {
	ObjectNotFoundException onfex = new ObjectNotFoundException("id", TestBean.class.getName());
	given(session.load(TestBean.class, "id")).willThrow(onfex);
	try {
		hibernateTemplate.load(TestBean.class, "id");
		fail("Should have thrown HibernateObjectRetrievalFailureException");
	}
	catch (HibernateObjectRetrievalFailureException ex) {
		// expected
		assertEquals(TestBean.class.getName(), ex.getPersistentClassName());
		assertEquals("id", ex.getIdentifier());
		assertEquals(onfex, ex.getCause());
	}
	verify(session).close();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:HibernateTemplateTests.java

示例4: findOrCreateMessage

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
/**
 * Find or create message.
 *
 * @param aMessage
 *            the a message
 * @param session
 *            the session
 * @return the message
 */
private synchronized Message findOrCreateMessage(final Message aMessage,
        final Session session) {
	Message message = null;
	try {
		message = this.findMessage(aMessage, session);
		if (null == message) {
			session.saveOrUpdate(aMessage.getPoster());
			message = aMessage;
			session.saveOrUpdate(aMessage);
			// messagesCache.put(key, message);
		}
	}
	catch (final ObjectNotFoundException e) {
		HibernateHelper.logger.warn(message.getPoster(), e);
	}
	return message;

}
 
开发者ID:leonarduk,项目名称:unison,代码行数:28,代码来源:HibernateHelper.java

示例5: onSubmit_shouldPurgeTheProvider

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
/**
 * @verifies should purge the provider
 * @see org.openmrs.web.controller.provider.ProviderFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      String, String, String, String, org.openmrs.Provider,
 *      org.springframework.validation.BindingResult, org.springframework.ui.ModelMap)
 */
@Test(expected = ObjectNotFoundException.class)
public void onSubmit_shouldPurgeTheProvider() throws Exception {
	executeDataSet(PROVIDERS_ATTRIBUTES_XML);
	executeDataSet(PROVIDERS_XML);
	Provider provider = Context.getProviderService().getProvider(2);
	ProviderAttributeType providerAttributeType = Context.getProviderService().getProviderAttributeType(1);
	MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest();
	BindException errors = new BindException(provider, "provider");
	ProviderFormController providerFormController = (ProviderFormController) applicationContext
	        .getBean("providerFormController");
	providerFormController.onSubmit(mockHttpServletRequest, null, null, null, "purge", provider, errors,
	    createModelMap(providerAttributeType));
	Context.flushSession();
	Assert.assertNull(Context.getProviderService().getProvider(2));
}
 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:22,代码来源:ProviderFormControllerTest.java

示例6: removeTransientEntries

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
public void removeTransientEntries(Map<Long, String> transientMap) {
    CalendarEntry entry;
    Transaction tx = _persister.getOrBeginTransaction();
    for (Long entryID : transientMap.keySet()) {
        String status = transientMap.get(entryID);
        if (status.equals(TRANSIENT_FLAG)) {
            try {
                entry = (CalendarEntry) _persister.load(CalendarEntry.class, entryID);
                _persister.delete(entry, tx);
            }
            catch (ObjectNotFoundException onfe) {
                // nothing to remove if not found
            }
        }
        else {
            entry = (CalendarEntry) _persister.get(CalendarEntry.class, entryID);
            if (entry != null) {
                entry.setStatus(status);
                _persister.update(entry, tx);
            }
        }
    }
}
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:24,代码来源:ResourceCalendar.java

示例7: canManipulateReport

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
private boolean canManipulateReport(PostReport report) {
	int[] forumIds = this.userSession.getRoleManager()
			.getRoleValues(SecurityConstants.FORUM);

	for (int forumId : forumIds) {
		// Make sure the user is removing a report from a forum he can
		// moderate
		try {
			if (forumId == report.getPost().getForum().getId()) {
				return true;
			}
		} catch (ObjectNotFoundException e) {
			return true;
		}
	}

	return false;
}
 
开发者ID:eclipse123,项目名称:JForum,代码行数:19,代码来源:PostReportController.java

示例8: handleLastPostDeleted

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
private void handleLastPostDeleted(Post post) {
	boolean isLastPost = false;

	try {
		// FIXME: post.getTopic.getLastPost() may throw this exception,
		// because the post itself was deleted before this method,
		// and a call to post.getTopic().getLastPost() may issue
		// a query to load the last post of such topic, which
		// won't exist, of course. So, is this expected, or should
		// we handle this using another approach?
		isLastPost = post.getTopic().getLastPost().equals(post);
	}
	catch (ObjectNotFoundException e) {
		isLastPost = true;
	}

	if (isLastPost) {
		post.getTopic().setLastPost(this.topicRepository.getLastPost(post.getTopic()));
	}
}
 
开发者ID:eclipse123,项目名称:JForum,代码行数:21,代码来源:TopicPostEvent.java

示例9: handleFirstPostDeleted

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
private boolean handleFirstPostDeleted(Post post) {
	boolean isFirstPost = false;

	try {
		isFirstPost = post.getTopic().getFirstPost().equals(post);
	}
	catch (ObjectNotFoundException e) {
		isFirstPost = true;
	}

	if (isFirstPost) {
		Post firstPost = this.topicRepository.getFirstPost(post.getTopic());
		post.getTopic().setFirstPost(firstPost);
		post.getTopic().setUser(firstPost.getUser());

		return true;
	}

	return false;
}
 
开发者ID:eclipse123,项目名称:JForum,代码行数:21,代码来源:TopicPostEvent.java

示例10: deleted

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
/**
 * The actions are:
 * <ul>
 * 	<li> If last post, update forum.lastPost
 * </ul>
 */
@Override
public void deleted(Post post) {
	boolean isLastPost = false;

	try {
		// FIXME: Check TopicPostEvent#handleLastPostDeleted
		isLastPost = post.equals(post.getForum().getLastPost());
	}
	catch (ObjectNotFoundException e) {
		isLastPost = true;
	}

	if (isLastPost) {
		Post lastPost = this.repository.getLastPost(post.getForum());
		post.getForum().setLastPost(lastPost);
	}
}
 
开发者ID:eclipse123,项目名称:JForum,代码行数:24,代码来源:ForumPostEvent.java

示例11: deleted

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
/**
 * The actions are:
 * <ul>
 * 	<li> If topic.lastPost == forum.lastPost, update forum.lastPost
 * </ul>
 */
@Override
public void deleted(Topic topic) {
	Forum forum = topic.getForum();
	boolean topicMatches = false;

	try {
		// FIXME: Check TopiPostEvent#handleLastPostDeleted
		topicMatches = forum.getLastPost() == null
			? true
			: forum.getLastPost().getTopic().equals(topic);
	}
	catch (ObjectNotFoundException e) {
		topicMatches = true;
	}

	if (topicMatches) {
		forum.setLastPost(this.repository.getLastPost(forum));
	}
}
 
开发者ID:eclipse123,项目名称:JForum,代码行数:26,代码来源:ForumTopicEvent.java

示例12: removeItem

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
public void removeItem(Item item) {
    try {

        if (item == null) {
            throw new IllegalArgumentException("item cannot be null");
        }

        if (item instanceof HomeCollectionItem) {
            throw new IllegalArgumentException("cannot remove root item");
        }

        removeItemInternal(item);
        getSession().flush();

    } catch (ObjectNotFoundException onfe) {
        throw new ItemNotFoundException("item not found");
    } catch (ObjectDeletedException ode) {
        throw new ItemNotFoundException("item not found");
    } catch (UnresolvableObjectException uoe) {
        throw new ItemNotFoundException("item not found");
    } catch (HibernateException e) {
        getSession().clear();
        throw SessionFactoryUtils.convertHibernateAccessException(e);
    }
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:26,代码来源:ItemDaoImpl.java

示例13: getAuthor

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
public String getAuthor() {
    try {
        // try to handle as identity id
        final Identity identity = getBaseSecurity().loadIdentityByKey(Long.valueOf(author));
        if (identity == null) {
            return author;
        }
        return identity.getName();
    } catch (final NumberFormatException nEx) {
        return author;
    } catch (final ObjectNotFoundException oEx) {
        DBFactory.getInstanceForClosing().rollbackAndCloseSession();
        return author;
    } catch (final Throwable th) {
        DBFactory.getInstanceForClosing().rollbackAndCloseSession();
        return author;
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:19,代码来源:DialogElement.java

示例14: lookupConfigFileByChannelAndName

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
/**
 * Lookup a ConfigFile by its channel's id and config file name's id
 * @param channel The file's config channel id
 * @param name The file's config file name id
 * @return the ConfigFile found or null if not found.
 */
public static ConfigFile lookupConfigFileByChannelAndName(Long channel, Long name) {
    Session session = HibernateFactory.getSession();
    Query query =
        session.getNamedQuery("ConfigFile.findByChannelAndName")
                .setLong("channel_id", channel.longValue())
                .setLong("name_id", name.longValue())
                .setLong("state_id", ConfigFileState.normal().
                                                getId().longValue())
                //Retrieve from cache if there
                .setCacheable(true);
    try {
        return (ConfigFile) query.uniqueResult();
    }
    catch (ObjectNotFoundException e) {
        return null;
    }
}
 
开发者ID:spacewalkproject,项目名称:spacewalk,代码行数:24,代码来源:ConfigurationFactory.java

示例15: getActionChain

import org.hibernate.ObjectNotFoundException; //导入依赖的package包/类
/**
 * Gets an Action Chain by id.
 * @param requestor the user whose chain we're looking for
 * @param id the id
 * @return the Action Chain
 * @throws ObjectNotFoundException if there is no such id accessible to the requestor
 */
public static ActionChain getActionChain(User requestor, Long id)
throws ObjectNotFoundException {
    log.debug("Looking up Action Chain with id " + id);
    if (id == null) {
        return null;
    }
    ActionChain ac = (ActionChain) getSession()
                    .createCriteria(ActionChain.class)
                    .add(Restrictions.eq("id", id))
                    .add(Restrictions.eq("user", requestor))
                    .uniqueResult();
    if (ac == null) {
        throw new ObjectNotFoundException(ActionChain.class,
                        "ActionChain Id " + id + " not found for User " +
                        requestor.getLogin());
    }
    return ac;
}
 
开发者ID:spacewalkproject,项目名称:spacewalk,代码行数:26,代码来源:ActionChainFactory.java


注:本文中的org.hibernate.ObjectNotFoundException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。