Java Code Examples for org.hibernate.cfg.NotYetImplementedException

The following examples show how to use org.hibernate.cfg.NotYetImplementedException. 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
@Override
public boolean usesJoinTable() {
	switch ( elementSource.getNature() ) {
		case BASIC:
		case AGGREGATE:
		case ONE_TO_MANY:
			return false;
		case MANY_TO_MANY:
			return true;
		case MANY_TO_ANY:
			throw new NotYetImplementedException(
					String.format( "%s is not implemented yet.", elementSource.getNature() )
			);
		default:
			throw new AssertionFailure(
					String.format(
							"Unexpected plural attribute element source nature: %s",
							elementSource.getNature()
					)
			);
	}
}
 
Example 2
@Override
public void execute() throws HibernateException {
	throw new NotYetImplementedException();
}
 
Example 3
@Override
public InputStream getAsciiStream(int columnIndex) {
	throw new NotYetImplementedException( "This type hasn't been implemented yet" );
}
 
Example 4
@Override
public InputStream getUnicodeStream(int columnIndex) {
	throw new NotYetImplementedException( "This type hasn't been implemented yet" );
}
 
Example 5
@Override
public InputStream getBinaryStream(int columnIndex) {
	throw new NotYetImplementedException( "This type hasn't been implemented yet" );
}
 
Example 6
Source Project: lams   Source File: QueryBinder.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void bindNativeQuery(
		org.hibernate.annotations.NamedNativeQuery queryAnn,
		MetadataBuildingContext context) {
	if ( queryAnn == null ) {
		return;
	}

	//ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() );
	if ( BinderHelper.isEmptyAnnotationValue( queryAnn.name() ) ) {
		throw new AnnotationException( "A named query must have a name when used in class or package level" );
	}

	NamedSQLQueryDefinition query;
	String resultSetMapping = queryAnn.resultSetMapping();
	if ( !BinderHelper.isEmptyAnnotationValue( resultSetMapping ) ) {
		//sql result set usage
		query = new NamedSQLQueryDefinitionBuilder().setName( queryAnn.name() )
				.setQuery( queryAnn.query() )
				.setResultSetRef( resultSetMapping )
				.setQuerySpaces( null )
				.setCacheable( queryAnn.cacheable() )
				.setCacheRegion(
						BinderHelper.isEmptyAnnotationValue( queryAnn.cacheRegion() ) ?
								null :
								queryAnn.cacheRegion()
				)
				.setTimeout( queryAnn.timeout() < 0 ? null : queryAnn.timeout() )
				.setFetchSize( queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize() )
				.setFlushMode( getFlushMode( queryAnn.flushMode() ) )
				.setCacheMode( getCacheMode( queryAnn.cacheMode() ) )
				.setReadOnly( queryAnn.readOnly() )
				.setComment( BinderHelper.isEmptyAnnotationValue( queryAnn.comment() ) ? null : queryAnn.comment() )
				.setParameterTypes( null )
				.setCallable( queryAnn.callable() )
				.createNamedQueryDefinition();
	}
	else if ( !void.class.equals( queryAnn.resultClass() ) ) {
		//class mapping usage
		//FIXME should be done in a second pass due to entity name?
		final NativeSQLQueryRootReturn entityQueryReturn =
				new NativeSQLQueryRootReturn( "alias1", queryAnn.resultClass().getName(), new HashMap(), LockMode.READ );
		query = new NamedSQLQueryDefinitionBuilder().setName( queryAnn.name() )
				.setQuery( queryAnn.query() )
				.setQueryReturns( new NativeSQLQueryReturn[] {entityQueryReturn} )
				.setQuerySpaces( null )
				.setCacheable( queryAnn.cacheable() )
				.setCacheRegion(
						BinderHelper.isEmptyAnnotationValue( queryAnn.cacheRegion() ) ?
								null :
								queryAnn.cacheRegion()
				)
				.setTimeout( queryAnn.timeout() < 0 ? null : queryAnn.timeout() )
				.setFetchSize( queryAnn.fetchSize() < 0 ? null : queryAnn.fetchSize() )
				.setFlushMode( getFlushMode( queryAnn.flushMode() ) )
				.setCacheMode( getCacheMode( queryAnn.cacheMode() ) )
				.setReadOnly( queryAnn.readOnly() )
				.setComment( BinderHelper.isEmptyAnnotationValue( queryAnn.comment() ) ? null : queryAnn.comment() )
				.setParameterTypes( null )
				.setCallable( queryAnn.callable() )
				.createNamedQueryDefinition();
	}
	else {
		throw new NotYetImplementedException( "Pure native scalar queries are not yet supported" );
	}
	context.getMetadataCollector().addNamedNativeQuery( query );
	if ( LOG.isDebugEnabled() ) {
		LOG.debugf( "Binding named native query: %s => %s", query.getName(), queryAnn.query() );
	}
}
 
Example 7
Source Project: lams   Source File: ResultSetProcessorImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public ScrollableResultSetProcessor toOnDemandForm() {
	// todo : implement
	throw new NotYetImplementedException();
}
 
Example 8
Source Project: lams   Source File: EntityMetamodel.java    License: GNU General Public License v2.0 4 votes vote down vote up
public GenerationStrategyPair buildPair() {
	if ( hadInMemoryGeneration && hadInDatabaseGeneration ) {
		throw new ValueGenerationStrategyException(
				"Composite attribute [" + mappingProperty.getName() + "] contained both in-memory"
						+ " and in-database value generation"
		);
	}
	else if ( hadInMemoryGeneration ) {
		throw new NotYetImplementedException( "Still need to wire in composite in-memory value generation" );

	}
	else if ( hadInDatabaseGeneration ) {
		final Component composite = (Component) mappingProperty.getValue();

		// we need the numbers to match up so we can properly handle 'referenced sql column values'
		if ( inDatabaseStrategies.size() != composite.getPropertySpan() ) {
			throw new ValueGenerationStrategyException(
					"Internal error : mismatch between number of collected in-db generation strategies" +
							" and number of attributes for composite attribute : " + mappingProperty.getName()
			);
		}

		// the base-line values for the aggregated InDatabaseValueGenerationStrategy we will build here.
		GenerationTiming timing = GenerationTiming.INSERT;
		boolean referenceColumns = false;
		String[] columnValues = new String[ composite.getColumnSpan() ];

		// start building the aggregate values
		int propertyIndex = -1;
		int columnIndex = 0;
		Iterator subProperties = composite.getPropertyIterator();
		while ( subProperties.hasNext() ) {
			propertyIndex++;
			final Property subProperty = (Property) subProperties.next();
			final InDatabaseValueGenerationStrategy subStrategy = inDatabaseStrategies.get( propertyIndex );

			if ( subStrategy.getGenerationTiming() == GenerationTiming.ALWAYS ) {
				// override the base-line to the more often "ALWAYS"...
				timing = GenerationTiming.ALWAYS;

			}
			if ( subStrategy.referenceColumnsInSql() ) {
				// override base-line value
				referenceColumns = true;
			}
			if ( subStrategy.getReferencedColumnValues() != null ) {
				if ( subStrategy.getReferencedColumnValues().length != subProperty.getColumnSpan() ) {
					throw new ValueGenerationStrategyException(
							"Internal error : mismatch between number of collected 'referenced column values'" +
									" and number of columns for composite attribute : " + mappingProperty.getName() +
									'.' + subProperty.getName()
					);
				}
				System.arraycopy(
						subStrategy.getReferencedColumnValues(),
						0,
						columnValues,
						columnIndex,
						subProperty.getColumnSpan()
				);
			}
		}

		// then use the aggregated values to build the InDatabaseValueGenerationStrategy
		return new GenerationStrategyPair(
				new InDatabaseValueGenerationStrategyImpl( timing, referenceColumns, columnValues )
		);
	}
	else {
		return NO_GEN_PAIR;
	}
}
 
Example 9
Source Project: lams   Source File: EntityGraphImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public <X> Subgraph<? extends X> addSubclassSubgraph(Class<? extends X> type) {
	// todo : implement
	throw new NotYetImplementedException();
}
 
Example 10
/**
 * Appends SELECT clause in query builder and returns either
 * list of selections if a query is a projection query, or empty
 * list if a single entity query
 */
private List<ScalarReturn> select(StringBuilder queryBuilder) {
	queryBuilder.append( "SELECT " );
	String rootAlias = propertyHelper.findAliasForType( propertyHelper.getRootEntity() );

	// is selected unqualified root entity (e.g. "from Hypothesis"),
	// or a single entity defined by alias (e.g. "select h from Hypothesis h")
	if ( propertyHelper.getSelections().isEmpty()
		|| ( propertyHelper.getSelections().size() == 1
		&& propertyHelper.getSelections().get( 0 ).getNodeNamesWithoutAlias().isEmpty() ) ) {
		String selectionAlias = propertyHelper.getSelections().isEmpty()
			? rootAlias
			: propertyHelper.getSelections().get( 0 ).getFirstNode().getName();
		queryBuilder
			.append( selectionAlias ).append( "._KEY, " )
			.append( selectionAlias ).append( "._VAL" );
		return Collections.emptyList();
	}

	// else, treat as projection selection
	List<ScalarReturn> selections = new ArrayList<>();
	int columnNumber = 0;
	Iterator<PropertyPath> i = propertyHelper.getSelections().iterator();
	while ( i.hasNext() ) {
		PropertyPath path = i.next();
		String alias = path.getFirstNode().isAlias()
			? path.getFirstNode().getName() : rootAlias;

		String columnName;
		List<String> propertyPath = path.getNodeNamesWithoutAlias();
		String entityType = propertyHelper.getEntityNameByAlias( alias );
		Type type = propertyHelper.getPropertyType( entityType, propertyPath );
		if ( type.isEntityType() ) {
			// though it may be better to load both key and value
			// in one query, OgmQueryLoader requires only key
			columnName = "_KEY";
		}
		else if ( type.isComponentType() ) {
			throw new NotYetImplementedException( "Embeddables in projection selection" );
		}
		else {
			columnName = propertyHelper.getColumnName( entityType, propertyPath );
			EntityKeyMetadata entityKey = propertyHelper.getKeyMetaData( entityType );
			if ( entityKey.getColumnNames().length == 1
				&& entityKey.getColumnNames()[0].equals( columnName ) ) {
				columnName = "_KEY";
			}
		}
		String columnAlias = "col_" + ( columnNumber++ );
		queryBuilder
			.append( alias ).append( '.' ).append( columnName )
			.append( " as " ).append( columnAlias );
		selections.add( new ScalarReturn( type, columnAlias ) );

		if ( i.hasNext() ) {
			queryBuilder.append( ',' ).append( ' ' );
		}
	}
	return selections;
}
 
Example 11
void setRootEntity(String entityName) {
	if ( rootEntityType != null && !rootEntityType.equals( entityName ) ) {
		throw new NotYetImplementedException( "Multiple root entities" );
	}
	rootEntityType = entityName;
}
 
Example 12
/**
	 * Returns the {@link PropertyIdentifier} for the given property path.
	 *
	 * In passing, it creates all the necessary aliases for embedded/associations.
	 *
	 * @param path the path to the property
	 * @param targetEntityType the type of the entity
	 * @return the {@link PropertyIdentifier}
	 */
	PropertyIdentifier getPropertyIdentifier(PropertyPath path, String targetEntityType) {
		// we analyze the property path to find all the associations/embedded
		// which are in the way and create proper aliases for them

		List<String> propertyPath = path.getNodeNamesWithoutAlias();
		String entityAlias;
		boolean isLastElementAssociation = true;
		if ( path.getFirstNode().isAlias() ) {
			entityAlias = path.getFirstNode().getName();
		}
		else {
			entityAlias = findAliasForType( targetEntityType );
		}
		String propertyEntityType = entityNameByAlias.get( entityAlias );
		if ( propertyEntityType == null ) {
			propertyEntityType = targetEntityType;
		}

		String propertyAlias = entityAlias;
		String propertyName;

		List<String> currentPropertyPath = new ArrayList<>();
		List<String> lastAssociationPath = new ArrayList<>();

		OgmEntityPersister currentPersister = getPersister( propertyEntityType );
		OgmEntityPersister predPersister = currentPersister;
		String predJoinAlias = entityAlias;

		for ( String property : propertyPath ) {
			currentPropertyPath.add( property );
			Type currentPropertyType = getPropertyType( propertyEntityType, Collections.singletonList( property ) );

			if ( currentPropertyType.isAssociationType() ) {
				propertyEntityType = currentPropertyType.getName();
				currentPersister = getPersister( propertyEntityType );
				AssociationType associationPropertyType = (AssociationType) currentPropertyType;
				Joinable associatedJoinable = associationPropertyType.getAssociatedJoinable( getSessionFactory() );
				if ( associatedJoinable.isCollection()
					&& ( (OgmCollectionPersister) associatedJoinable ).getType().isComponentType() ) {
					// we have a collection of embedded
					throw new NotYetImplementedException( "Query with collection of embeddables" );
//					propertyAlias = aliasResolver.createAliasForEmbedded( entityAlias, currentPropertyPath, optionalMatch );
				}
				else {
					// last in path? - no need for join
					if ( currentPropertyPath.size() == propertyPath.size() ) {
						propertyName = getColumnName( predPersister.getEntityType().getName(),
							Collections.singletonList( property ) );
						return new PropertyIdentifier( predJoinAlias, propertyName );
					}
					// else, we register an implicit join
					lastAssociationPath.add( property );
					throw new NotYetImplementedException( "Query on associated property" );
					// predPersister = currentPersister;
					// isLastElementAssociation = true;
				}
			}
			else if ( currentPropertyType.isComponentType()
				&& !isIdProperty( currentPersister, propertyPath.subList( lastAssociationPath.size(), propertyPath.size() ) ) ) {
				// we are in the embedded case and the embedded is not the id of the entity (the id is stored as normal
				// properties)
				String embeddedProperty = String.join( ".", propertyPath.subList( lastAssociationPath.size(), propertyPath.size() ) );
				String[] columns = currentPersister.getPropertyColumnNames( embeddedProperty );
				if ( columns.length > 1 ) {
					throw new NotYetImplementedException( "Query with composite-ID association" );
				}
				return new PropertyIdentifier( propertyAlias, columns[0] );
			}
			else {
				isLastElementAssociation = false;
			}
		}

		if ( isLastElementAssociation ) {
			// even the last element is an association, we need to find a suitable identifier property
			propertyName = getPersister( propertyEntityType ).getIdentifierPropertyName();
		}
		else {
			// the last element is a property so we can build the rest with this property
			propertyName = getColumnName( propertyEntityType, propertyPath.subList( lastAssociationPath.size(), propertyPath.size() ) );
		}
		return new PropertyIdentifier( predJoinAlias, propertyName );
	}