org.hibernate.TypeMismatchException#org.hibernate.query.internal.AbstractProducedQuery源码实例Demo

下面列出了org.hibernate.TypeMismatchException#org.hibernate.query.internal.AbstractProducedQuery 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lams   文件: NamedQueryLoader.java
@Override
public Object load(Serializable id, Object optionalObject, SharedSessionContractImplementor session) {
	LOG.debugf( "Loading entity: %s using named query: %s", persister.getEntityName(), queryName );

	// IMPL NOTE: essentially we perform the named query (which loads the entity into the PC), and then
	// do an internal lookup of the entity from the PC.

	final AbstractProducedQuery query = (AbstractProducedQuery) session.getNamedQuery( queryName );
	if ( query.getParameterMetadata().hasNamedParameters() ) {
		query.setParameter( query.getNamedParameters()[0], id, persister.getIdentifierType() );
	}
	else {
		query.setParameter( position, id, persister.getIdentifierType() );
	}

	query.setOptionalId( id );
	query.setOptionalEntityName( persister.getEntityName() );
	query.setOptionalObject( optionalObject );
	query.setFlushMode( FlushMode.MANUAL );
	query.list();

	// now look up the object we are really interested in!
	// (this lets us correctly handle proxies and multi-row or multi-column queries)
	return session.getPersistenceContext().getEntity( session.generateEntityKey( id, persister ) );

}
 
源代码2 项目: hibernate-reactive   文件: ReactiveQuery.java
static <T> T convertQueryException(T result, Throwable e,
								   AbstractProducedQuery<?> query) {
	if ( e instanceof QueryExecutionRequestException) {
		throw new IllegalStateException( e );
	}
	if ( e instanceof TypeMismatchException) {
		throw new IllegalStateException( e );
	}
	if ( e instanceof HibernateException) {
		throw query.getProducer().getExceptionConverter()
				.convert( (HibernateException) e, query.getLockOptions() );
	}
	return CompletionStages.returnOrRethrow( e, result );
}
 
源代码3 项目: hibernate-reactive   文件: ReactiveQuery.java
static <R> R extractUniqueResult(List<R> list, AbstractProducedQuery<R> query) {
	try {
		if ( list.size() == 0 ) {
			throw new NoResultException( "No entity found for query" );
		}
		return AbstractProducedQuery.uniqueElement( list );
	}
	catch (HibernateException e) {
		throw query.getProducer().getExceptionConverter()
				.convert( e, query.getLockOptions() );
	}
}
 
源代码4 项目: hibernate-types   文件: SQLExtractor.java
/**
 * Get the underlying SQL generated by the provided JPA query.
 *
 * @param query JPA query
 * @return the underlying SQL generated by the provided JPA query
 */
public static String from(Query query) {
    AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class);
    String[] sqls = abstractProducedQuery
        .getProducer()
        .getFactory()
        .getQueryPlanCache()
        .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap())
        .getSqlStrings();

    return sqls.length > 0 ? sqls[0] : null;
}
 
源代码5 项目: lams   文件: CriteriaImpl.java
@Override
public Object uniqueResult() throws HibernateException {
	return AbstractProducedQuery.uniqueElement( list() );
}