Java Code Examples for org.hibernate.loader.custom.Return

The following examples show how to use org.hibernate.loader.custom.Return. These examples are extracted from open source projects. 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 Project: lams   Source File: OutputsImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
private EntityAliases[] interpretEntityAliases(List<Return> customQueryReturns) {
	final List<EntityAliases> entityAliases = new ArrayList<>();
	for ( Return queryReturn : customQueryReturns ) {
		if ( !RootReturn.class.isInstance( queryReturn ) ) {
			continue;
		}

		entityAliases.add( ( (RootReturn) queryReturn ).getEntityAliases() );
	}

	if ( entityAliases.isEmpty() ) {
		return NO_ALIASES;
	}

	return entityAliases.toArray( new EntityAliases[ entityAliases.size() ] );
}
 
Example 2
Source Project: lams   Source File: OutputsImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static CustomLoaderExtension buildSpecializedCustomLoader(final ResultContext context) {
	// might be better to just manually construct the Return(s).. SQLQueryReturnProcessor does a lot of
	// work that is really unnecessary here.
	final SQLQueryReturnProcessor processor = new SQLQueryReturnProcessor(
			context.getQueryReturns(),
			context.getSession().getFactory()
	);
	processor.process();
	final List<org.hibernate.loader.custom.Return> customReturns = processor.generateCallableReturns();

	CustomQuery customQuery = new CustomQuery() {
		@Override
		public String getSQL() {
			return context.getSql();
		}

		@Override
		public Set<String> getQuerySpaces() {
			return context.getSynchronizedQuerySpaces();
		}

		@Override
		public List<ParameterBinder> getParameterValueBinders() {
			// no parameters in terms of embedded in the SQL string
			return Collections.emptyList();
		}

		@Override
		public List<org.hibernate.loader.custom.Return> getCustomQueryReturns() {
			return customReturns;
		}
	};

	return new CustomLoaderExtension(
			customQuery,
			context.getQueryParameters(),
			context.getSession()
	);
}