org.hibernate.query.internal.NativeQueryImpl Java Examples

The following examples show how to use org.hibernate.query.internal.NativeQueryImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSharedSessionContract.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings({"WeakerAccess", "unchecked"})
protected <T> NativeQueryImplementor createNativeQuery(NamedSQLQueryDefinition queryDefinition, Class<T> resultType) {
	if ( resultType != null && !Tuple.class.equals(resultType)) {
		resultClassChecking( resultType, queryDefinition );
	}

	final NativeQueryImpl query = new NativeQueryImpl(
			queryDefinition,
			this,
			factory.getQueryPlanCache().getSQLParameterMetadata( queryDefinition.getQueryString(), false )
	);
	if (Tuple.class.equals(resultType)) {
		query.setResultTransformer(new NativeQueryTupleTransformer());
	}
	query.setHibernateFlushMode( queryDefinition.getFlushMode() );
	query.setComment( queryDefinition.getComment() != null ? queryDefinition.getComment() : queryDefinition.getName() );
	if ( queryDefinition.getLockOptions() != null ) {
		query.setLockOptions( queryDefinition.getLockOptions() );
	}

	initQueryFromNamedDefinition( query, queryDefinition );
	applyQuerySettingsAndHints( query );

	return query;
}
 
Example #2
Source File: AbstractSharedSessionContract.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected NativeQueryImplementor getNativeQueryImplementor(
		String queryString,
		boolean isOrdinalParameterZeroBased) {
	checkOpen();
	checkTransactionSynchStatus();
	delayedAfterCompletion();

	try {
		NativeQueryImpl query = new NativeQueryImpl(
				queryString,
				false,
				this,
				getFactory().getQueryPlanCache().getSQLParameterMetadata( queryString, isOrdinalParameterZeroBased )
		);
		query.setComment( "dynamic native SQL query" );
		return query;
	}
	catch ( RuntimeException he ) {
		throw exceptionConverter.convert( he );
	}
}
 
Example #3
Source File: BaseRepositoryImpl.java    From web-flash with MIT License 5 votes vote down vote up
@Override
public List<Map> queryBySql(String sql) {
    Query query = entityManager.createNativeQuery(sql);
    query.unwrap(NativeQueryImpl.class)
            .setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
    List list = query.getResultList();
    return list;
}
 
Example #4
Source File: AbstractSharedSessionContract.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private NativeQueryImplementor getNativeQueryImplementor(
		NamedSQLQueryDefinition queryDefinition,
		ParameterMetadata parameterMetadata) {
	final NativeQueryImpl query = new NativeQueryImpl(
			queryDefinition,
			this,
			parameterMetadata
	);
	query.setComment( queryDefinition.getComment() != null ? queryDefinition.getComment() : queryDefinition.getName() );

	initQueryFromNamedDefinition( query, queryDefinition );
	applyQuerySettingsAndHints( query );

	return query;
}