• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java QueryTimeoutException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: validarUsuario

import javax.persistence.QueryTimeoutException; //导入依赖的package包/类
public Pessoa validarUsuario(String log, String pass){
	final CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
	
	final CriteriaQuery<Pessoa> cquery = cb.createQuery(Pessoa.class);
	final Root<Pessoa> root = cquery.from(Pessoa.class);
	final List<Predicate> condicoes = new ArrayList<Predicate>();

	condicoes.add(cb.equal(root.get("usuario").get("login"), log));
	condicoes.add(cb.equal(root.get("usuario").get("senha"), pass));
	
	cquery.select(root).where(condicoes.toArray(new Predicate[]{}));
	Pessoa pessoa = new Pessoa();
	try{
		pessoa = getEntityManager().createQuery(cquery).getSingleResult();
	} catch (Exception e) {
		throw new QueryTimeoutException("Usuário ou senha invalido!");
	}	
   	
   	return pessoa;
}
 
开发者ID:kashm1r,项目名称:photoiff,代码行数:21,代码来源:PerfilService.java


示例2: validarLoginAdminstrador

import javax.persistence.QueryTimeoutException; //导入依赖的package包/类
public Pessoa validarLoginAdminstrador(String login, String senha){
	final CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
	
	final CriteriaQuery<Pessoa> cquery = cb.createQuery(Pessoa.class);
	final Root<Pessoa> root = cquery.from(Pessoa.class);
	final List<Predicate> condicoes = new ArrayList<Predicate>();
	
	condicoes.add(cb.equal(root.get("usuario").get("matricula"), login));
	condicoes.add(cb.equal(root.get("usuario").get("senha"),senha));
	
	cquery.select(root).where(condicoes.toArray(new Predicate[]{}));
	Pessoa pessoa = new Pessoa();
	try{
		pessoa = getEntityManager().createQuery(cquery).getSingleResult();
	}catch (Exception e) {
		throw new QueryTimeoutException("Matricula ou Senha Invalidas");
	}
	
	return pessoa;
}
 
开发者ID:kashm1r,项目名称:photoiff,代码行数:21,代码来源:GenericService.java


示例3: runBackup

import javax.persistence.QueryTimeoutException; //导入依赖的package包/类
/**
 * Creates a Backup of the Database in the directory specified in
 * config.properties.
 *
 * @param name the name of the Backup.
 *
 * @return Backup entinty.
 *
 * @throws QueryTimeoutException if the query should fail.
 * @throws PersistenceException if persisting should fail.
 * @Throws IOException if config.properties is not readable.
 */
public Backup runBackup(String name) throws QueryTimeoutException,
       PersistenceException, IOException {
    Properties props = ServerProperties.getProperties();
    Date date = new Date();
    String path = props.getProperty(dirPropertyKey)
            + name + "_" + getDateAsString(date);

    StoredProcedureQuery query = em.createStoredProcedureQuery(
            "SYSCS_UTIL.SYSCS_BACKUP_DATABASE");
    query.registerStoredProcedureParameter(1, String.class,
            ParameterMode.IN);
    query.setParameter(1, path);
    query.execute();
    log.debug("Backup query executed!");

    Backup backup =  generateBackup(name, path, date, getDirectorySize(new File(path)));

    return backup;
}
 
开发者ID:stefanoberdoerfer,项目名称:exmatrikulator,代码行数:32,代码来源:BackupService.java


示例4: toRuntimeException

import javax.persistence.QueryTimeoutException; //导入依赖的package包/类
/**
 * 将异常包装为RuntimeException
 * 
 * @param e
 * @return
 */
public static PersistenceException toRuntimeException(SQLException e) {
	String s = e.getSQLState();
	if (e instanceof SQLIntegrityConstraintViolationException) {
		return new EntityExistsException(e);
	} else if (e instanceof SQLTimeoutException) {
		return new QueryTimeoutException(s, e);
	}
	return new PersistenceException(s, e);
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:16,代码来源:DbUtils.java


示例5: convertJpaAccessExceptionIfPossible

import javax.persistence.QueryTimeoutException; //导入依赖的package包/类
/**
 * Convert the given runtime exception to an appropriate exception from the
 * {@code org.springframework.dao} hierarchy.
 * Return null if no translation is appropriate: any other exception may
 * have resulted from user code, and should not be translated.
 * <p>The most important cases like object not found or optimistic locking failure
 * are covered here. For more fine-granular conversion, JpaTransactionManager etc
 * support sophisticated translation of exceptions via a JpaDialect.
 * @param ex runtime exception that occurred
 * @return the corresponding DataAccessException instance,
 * or {@code null} if the exception should not be translated
 */
public static DataAccessException convertJpaAccessExceptionIfPossible(RuntimeException ex) {
	// Following the JPA specification, a persistence provider can also
	// throw these two exceptions, besides PersistenceException.
	if (ex instanceof IllegalStateException) {
		return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
	}
	if (ex instanceof IllegalArgumentException) {
		return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
	}

	// Check for well-known PersistenceException subclasses.
	if (ex instanceof EntityNotFoundException) {
		return new JpaObjectRetrievalFailureException((EntityNotFoundException) ex);
	}
	if (ex instanceof NoResultException) {
		return new EmptyResultDataAccessException(ex.getMessage(), 1, ex);
	}
	if (ex instanceof NonUniqueResultException) {
		return new IncorrectResultSizeDataAccessException(ex.getMessage(), 1, ex);
	}
	if (ex instanceof QueryTimeoutException) {
		return new org.springframework.dao.QueryTimeoutException(ex.getMessage(), ex);
	}
	if (ex instanceof LockTimeoutException) {
		return new CannotAcquireLockException(ex.getMessage(), ex);
	}
	if (ex instanceof PessimisticLockException) {
		return new PessimisticLockingFailureException(ex.getMessage(), ex);
	}
	if (ex instanceof OptimisticLockException) {
		return new JpaOptimisticLockingFailureException((OptimisticLockException) ex);
	}
	if (ex instanceof EntityExistsException) {
		return new DataIntegrityViolationException(ex.getMessage(), ex);
	}
	if (ex instanceof TransactionRequiredException) {
		return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
	}

	// If we have another kind of PersistenceException, throw it.
	if (ex instanceof PersistenceException) {
		return new JpaSystemException((PersistenceException) ex);
	}

	// If we get here, we have an exception that resulted from user code,
	// rather than the persistence provider, so we return null to indicate
	// that translation should not occur.
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:62,代码来源:EntityManagerFactoryUtils.java


示例6: testFindByNameQueryTimeoutException

import javax.persistence.QueryTimeoutException; //导入依赖的package包/类
@Test(expected = TagServiceException.class)
public void testFindByNameQueryTimeoutException(){
    Mockito.doThrow(QueryTimeoutException.class).when(tagRepository).executeNamedQuery(Mockito.anyString(), Mockito.anyMap());
    tagServiceImpl.findByName("nonexistent");
}
 
开发者ID:chr-krenn,项目名称:chr-krenn-fhj-ws2016-sd14-pse,代码行数:6,代码来源:TagServiceImplExceptionTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UnparsedSql类代码示例发布时间:2022-05-22
下一篇:
Java DocPaths类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap