Java Code Examples for org.hibernate.MappingException

The following are top voted examples for showing how to use org.hibernate.MappingException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: lams   File: StatefulPersistenceContext.java   View source code 6 votes vote down vote up
@Override
public boolean reassociateIfUninitializedProxy(Object value) throws MappingException {
	if ( value instanceof ElementWrapper ) {
		value = ( (ElementWrapper) value ).getElement();
	}

	if ( !Hibernate.isInitialized( value ) ) {
		final HibernateProxy proxy = (HibernateProxy) value;
		final LazyInitializer li = proxy.getHibernateLazyInitializer();
		reassociateProxy( li, proxy );
		return true;
	}
	else {
		return false;
	}
}
 
Example 2
Project: lams   File: AbstractQueryImpl.java   View source code 6 votes vote down vote up
private Type guessType(Class clazz) throws HibernateException {
	String typename = clazz.getName();
	Type type = session.getFactory().getTypeResolver().heuristicType(typename);
	boolean serializable = type!=null && type instanceof SerializableType;
	if (type==null || serializable) {
		try {
			session.getFactory().getEntityPersister( clazz.getName() );
		}
		catch (MappingException me) {
			if (serializable) {
				return type;
			}
			else {
				throw new HibernateException("Could not determine a type for class: " + typename);
			}
		}
		return ( (Session) session ).getTypeHelper().entity( clazz );
	}
	else {
		return type;
	}
}
 
Example 3
Project: lams   File: HbmBinder.java   View source code 6 votes vote down vote up
private static void parseIdentifierGeneratorRegistration(Element element, Mappings mappings) {
	String strategy = element.attributeValue( "name" );
	if ( StringHelper.isEmpty( strategy ) ) {
		throw new MappingException( "'name' attribute expected for identifier-generator elements" );
	}
	String generatorClassName = element.attributeValue( "class" );
	if ( StringHelper.isEmpty( generatorClassName ) ) {
		throw new MappingException( "'class' attribute expected for identifier-generator [[email protected]me=" + strategy + "]" );
	}

	try {
		Class generatorClass = ReflectHelper.classForName( generatorClassName );
		mappings.getIdentifierGeneratorFactory().register( strategy, generatorClass );
	}
	catch ( ClassNotFoundException e ) {
		throw new MappingException( "Unable to locate identifier-generator class [name=" + strategy + ", class=" + generatorClassName + "]" );
	}

}
 
Example 4
Project: lams   File: SerializableToBlobType.java   View source code 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void setParameterValues(Properties parameters) {
	ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE );
	if ( reader != null ) {
		setJavaTypeDescriptor( new SerializableTypeDescriptor<T>( reader.getReturnedClass() ) );
	} else {
		String className = parameters.getProperty( CLASS_NAME );
		if ( className == null ) {
			throw new MappingException( "No class name defined for type: " + SerializableToBlobType.class.getName() );
		}
		try {
			setJavaTypeDescriptor( new SerializableTypeDescriptor<T>( ReflectHelper.classForName( className ) ) );
		} catch ( ClassNotFoundException e ) {
			throw new MappingException( "Unable to load class from " + CLASS_NAME + " parameter", e );
		}
	}
}
 
Example 5
Project: lams   File: HbmBinder.java   View source code 6 votes vote down vote up
public static void bindOneToMany(Element node, OneToMany oneToMany, Mappings mappings)
		throws MappingException {

	oneToMany.setReferencedEntityName( getEntityName( node, mappings ) );

	String embed = node.attributeValue( "embed-xml" );
	// sometimes embed is set to the default value when not specified in the mapping,
	// so can't seem to determine if an attribute was explicitly set;
	// log a warning if embed has a value different from the default.
	if ( !StringHelper.isEmpty( embed ) &&  !"true".equals( embed ) ) {
		LOG.embedXmlAttributesNoLongerSupported();
	}
	oneToMany.setEmbedded( embed == null || "true".equals( embed ) );

	String notFound = node.attributeValue( "not-found" );
	oneToMany.setIgnoreNotFound( "ignore".equals( notFound ) );

}
 
Example 6
Project: lams   File: NamedProcedureCallDefinition.java   View source code 6 votes vote down vote up
NamedProcedureCallDefinition(NamedStoredProcedureQuery annotation) {
	this.registeredName = annotation.name();
	this.procedureName = annotation.procedureName();
	this.resultClasses = annotation.resultClasses();
	this.resultSetMappings = annotation.resultSetMappings();
	this.parameterDefinitions = new ParameterDefinitions( annotation.parameters() );
	this.hints = new QueryHintDefinition( annotation.hints() ).getHintsMap();

	final boolean specifiesResultClasses = resultClasses != null && resultClasses.length > 0;
	final boolean specifiesResultSetMappings = resultSetMappings != null && resultSetMappings.length > 0;

	if ( specifiesResultClasses && specifiesResultSetMappings ) {
		throw new MappingException(
				String.format(
						"NamedStoredProcedureQuery [%s] specified both resultClasses and resultSetMappings",
						registeredName
				)
		);
	}
}
 
Example 7
Project: lams   File: PersistentClass.java   View source code 6 votes vote down vote up
public void addSubclass(Subclass subclass) throws MappingException {
	// inheritance cycle detection (paranoid check)
	PersistentClass superclass = getSuperclass();
	while (superclass!=null) {
		if( subclass.getEntityName().equals( superclass.getEntityName() ) ) {
			throw new MappingException(
				"Circular inheritance mapping detected: " +
				subclass.getEntityName() +
				" will have it self as superclass when extending " +
				getEntityName()
			);
		}
		superclass = superclass.getSuperclass();
	}
	subclasses.add(subclass);
}
 
Example 8
Project: lams   File: PersistentClass.java   View source code 6 votes vote down vote up
protected void checkColumnDuplication(Set distinctColumns, Iterator columns) 
throws MappingException {
	while ( columns.hasNext() ) {
		Selectable columnOrFormula = (Selectable) columns.next();
		if ( !columnOrFormula.isFormula() ) {
			Column col = (Column) columnOrFormula;
			if ( !distinctColumns.add( col.getName() ) ) {
				throw new MappingException( 
						"Repeated column in mapping for entity: " +
						getEntityName() +
						" column: " +
						col.getName() + 
						" (should be mapped with insert=\"false\" update=\"false\")"
					);
			}
		}
	}
}
 
Example 9
Project: lams   File: HbmBinder.java   View source code 6 votes vote down vote up
private static void parseFetchProfile(Element element, Mappings mappings, String containingEntityName) {
	String profileName = element.attributeValue( "name" );
	FetchProfile profile = mappings.findOrCreateFetchProfile( profileName, MetadataSource.HBM );
	Iterator itr = element.elementIterator( "fetch" );
	while ( itr.hasNext() ) {
		final Element fetchElement = ( Element ) itr.next();
		final String association = fetchElement.attributeValue( "association" );
		final String style = fetchElement.attributeValue( "style" );
		String entityName = fetchElement.attributeValue( "entity" );
		if ( entityName == null ) {
			entityName = containingEntityName;
		}
		if ( entityName == null ) {
			throw new MappingException( "could not determine entity for fetch-profile fetch [" + profileName + "]:[" + association + "]" );
		}
		profile.addFetch( entityName, association, style );
	}
}
 
Example 10
Project: lams   File: EntityClass.java   View source code 6 votes vote down vote up
private IdType determineIdType() {
	List<AnnotationInstance> idAnnotations = findIdAnnotations( JPADotNames.ID );
	List<AnnotationInstance> embeddedIdAnnotations = findIdAnnotations( JPADotNames.EMBEDDED_ID );

	if ( !idAnnotations.isEmpty() && !embeddedIdAnnotations.isEmpty() ) {
		throw new MappingException(
				"@EmbeddedId and @Id cannot be used together. Check the configuration for " + getName() + "."
		);
	}

	if ( !embeddedIdAnnotations.isEmpty() ) {
		if ( embeddedIdAnnotations.size() == 1 ) {
			return IdType.EMBEDDED;
		}
		else {
			throw new AnnotationException( "Multiple @EmbeddedId annotations are not allowed" );
		}
	}

	if ( !idAnnotations.isEmpty() ) {
		return idAnnotations.size() == 1 ? IdType.SIMPLE : IdType.COMPOSED;
	}
	return IdType.NONE;
}
 
Example 11
Project: lams   File: OneToManyJoinWalker.java   View source code 6 votes vote down vote up
public OneToManyJoinWalker(
		QueryableCollection oneToManyPersister,
		int batchSize,
		String subquery,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	super( factory, loadQueryInfluencers );

	this.oneToManyPersister = oneToManyPersister;

	final OuterJoinLoadable elementPersister = (OuterJoinLoadable) oneToManyPersister.getElementPersister();
	final String alias = generateRootAlias( oneToManyPersister.getRole() );

	walkEntityTree(elementPersister, alias);

	List allAssociations = new ArrayList();
	allAssociations.addAll(associations);
	allAssociations.add( OuterJoinableAssociation.createRoot( oneToManyPersister.getCollectionType(), alias, getFactory() ) );
	initPersisters(allAssociations, LockMode.NONE);
	initStatementString(elementPersister, alias, batchSize, subquery);
}
 
Example 12
Project: lams   File: AbstractPropertyMapping.java   View source code 6 votes vote down vote up
protected void initIdentifierPropertyPaths(
		final String path,
		final EntityType etype,
		final String[] columns,
		final String[] columnReaders,
		final String[] columnReaderTemplates,
		final Mapping factory) throws MappingException {

	Type idtype = etype.getIdentifierOrUniqueKeyType( factory );
	String idPropName = etype.getIdentifierOrUniqueKeyPropertyName(factory);
	boolean hasNonIdentifierPropertyNamedId = hasNonIdentifierPropertyNamedId( etype, factory );

	if ( etype.isReferenceToPrimaryKey() ) {
		if ( !hasNonIdentifierPropertyNamedId ) {
			String idpath1 = extendPath(path, EntityPersister.ENTITY_ID);
			addPropertyPath(idpath1, idtype, columns, columnReaders, columnReaderTemplates, null);
			initPropertyPaths(idpath1, idtype, columns, columnReaders, columnReaderTemplates, null, factory);
		}
	}

	if (idPropName!=null) {
		String idpath2 = extendPath(path, idPropName);
		addPropertyPath(idpath2, idtype, columns, columnReaders, columnReaderTemplates, null);
		initPropertyPaths(idpath2, idtype, columns, columnReaders, columnReaderTemplates, null, factory);
	}
}
 
Example 13
Project: lams   File: JoinWalker.java   View source code 6 votes vote down vote up
/**
 * Does the mapping, and Hibernate default semantics, specify that
 * this association should be fetched by outer joining
 */
protected boolean isJoinedFetchEnabledInMapping(FetchMode config, AssociationType type) 
throws MappingException {
	if ( !type.isEntityType() && !type.isCollectionType() ) {
		return false;
	}
	else {
		if (config==FetchMode.JOIN) return true;
		if (config==FetchMode.SELECT) return false;
		if ( type.isEntityType() ) {
			//TODO: look at the owning property and check that it 
			//      isn't lazy (by instrumentation)
			EntityType entityType =(EntityType) type;
			EntityPersister persister = getFactory().getEntityPersister( entityType.getAssociatedEntityName() );
			return !persister.hasProxy();
		}
		else {
			return false;
		}
	}
}
 
Example 14
Project: lams   File: PropertyInferredData.java   View source code 5 votes vote down vote up
public AccessType getDefaultAccess() throws MappingException {
	AccessType accessType = defaultAccess;

	AccessType hibernateAccessType = AccessType.DEFAULT;
	AccessType jpaAccessType = AccessType.DEFAULT;

	org.hibernate.annotations.AccessType accessTypeAnnotation = property.getAnnotation( org.hibernate.annotations.AccessType.class );
	if ( accessTypeAnnotation != null ) {
		hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() );
	}

	Access access = property.getAnnotation( Access.class );
	if ( access != null ) {
		jpaAccessType = AccessType.getAccessStrategy( access.value() );
	}

	if ( hibernateAccessType != AccessType.DEFAULT
			&& jpaAccessType != AccessType.DEFAULT
			&& hibernateAccessType != jpaAccessType ) {

		StringBuilder builder = new StringBuilder();
		builder.append( property.toString() );
		builder.append(
				" defines @AccessType and @Access with contradicting values. Use of @Access only is recommended."
		);
		throw new MappingException( builder.toString() );
	}

	if ( hibernateAccessType != AccessType.DEFAULT ) {
		accessType = hibernateAccessType;
	}
	else if ( jpaAccessType != AccessType.DEFAULT ) {
		accessType = jpaAccessType;
	}
	return accessType;
}
 
Example 15
Project: lams   File: AbstractEntityPersister.java   View source code 5 votes vote down vote up
private void initDiscriminatorPropertyPath(Mapping mapping) throws MappingException {
	propertyMapping.initPropertyPaths( ENTITY_CLASS,
			getDiscriminatorType(),
			new String[]{getDiscriminatorColumnName()},
			new String[]{getDiscriminatorColumnReaders()},
			new String[]{getDiscriminatorColumnReaderTemplate()},
			new String[]{getDiscriminatorFormulaTemplate()},
			getFactory() );
}
 
Example 16
Project: lams   File: SimpleValue.java   View source code 5 votes vote down vote up
private void createParameterImpl() {
	try {
		String[] columnsNames = new String[columns.size()];
		for ( int i = 0; i < columns.size(); i++ ) {
			Selectable column = columns.get(i);
			if (column instanceof Column){
				columnsNames[i] = ((Column) column).getName();
			}
		}

		final XProperty xProperty = (XProperty) typeParameters.get( DynamicParameterizedType.XPROPERTY );
		// todo : not sure this works for handling @MapKeyEnumerated
		final Annotation[] annotations = xProperty == null
				? null
				: xProperty.getAnnotations();

		typeParameters.put(
				DynamicParameterizedType.PARAMETER_TYPE,
				new ParameterTypeImpl(
						ReflectHelper.classForName(
								typeParameters.getProperty( DynamicParameterizedType.RETURNED_CLASS )
						),
						annotations,
						table.getCatalog(),
						table.getSchema(),
						table.getName(),
						Boolean.valueOf( typeParameters.getProperty( DynamicParameterizedType.IS_PRIMARY_KEY ) ),
						columnsNames
				)
		);
	}
	catch ( ClassNotFoundException cnfe ) {
		throw new MappingException( "Could not create DynamicParameterizedType for type: " + typeName, cnfe );
	}
}
 
Example 17
Project: lams   File: LegacyBatchingCollectionInitializerBuilder.java   View source code 5 votes vote down vote up
@Override
protected CollectionInitializer createRealBatchingCollectionInitializer(
		QueryableCollection persister,
		int maxBatchSize,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize );
	Loader[] loaders = new Loader[ batchSizes.length ];
	for ( int i = 0; i < batchSizes.length; i++ ) {
		loaders[i] = new BasicCollectionLoader( persister, batchSizes[i], factory, loadQueryInfluencers );
	}
	return new LegacyBatchingCollectionInitializer( persister, batchSizes, loaders );
}
 
Example 18
Project: lams   File: EntityLoader.java   View source code 5 votes vote down vote up
public EntityLoader(
		OuterJoinLoadable persister,
		LockMode lockMode,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	this( persister, 1, lockMode, factory, loadQueryInfluencers );
}
 
Example 19
Project: lams   File: IdentifierCollection.java   View source code 5 votes vote down vote up
public void validate(Mapping mapping) throws MappingException {
	super.validate(mapping);
	if ( !getIdentifier().isValid(mapping) ) {
		throw new MappingException(
			"collection id mapping has wrong number of columns: " +
			getRole() +
			" type: " +
			getIdentifier().getType().getName()
		);
	}
}
 
Example 20
Project: lams   File: QueryTranslatorImpl.java   View source code 5 votes vote down vote up
/**
 * Compile the query (generate the SQL).
 *
 * @throws org.hibernate.MappingException Indicates problems resolving
 * things referenced in the query.
 * @throws org.hibernate.QueryException Generally some form of syntatic
 * failure.
 */
private void compile() throws QueryException, MappingException {
	LOG.trace( "Compiling query" );
	try {
		ParserHelper.parse( new PreprocessingParser( tokenReplacements ),
				queryString,
				ParserHelper.HQL_SEPARATORS,
				this );
		renderSQL();
	}
	catch ( QueryException qe ) {
		if ( qe.getQueryString() == null ) {
			throw qe.wrapWithQueryString( queryString );
		}
		else {
			throw qe;
		}
	}
	catch ( MappingException me ) {
		throw me;
	}
	catch ( Exception e ) {
		LOG.debug( "Unexpected query compilation problem", e );
		e.printStackTrace();
		throw new QueryException( "Incorrect query syntax", queryString, e );
	}

	postInstantiate();

	compiled = true;

}
 
Example 21
Project: lams   File: BasicCollectionJoinWalker.java   View source code 5 votes vote down vote up
protected JoinType getJoinType(
		OuterJoinLoadable persister,
		PropertyPath path,
		int propertyNumber,
		AssociationType associationType,
		FetchMode metadataFetchMode,
		CascadeStyle metadataCascadeStyle,
		String lhsTable,
		String[] lhsColumns,
		boolean nullable,
		int currentDepth) throws MappingException {
	JoinType joinType = super.getJoinType(
			persister,
			path,
			propertyNumber,
			associationType,
			metadataFetchMode,
			metadataCascadeStyle,
			lhsTable,
			lhsColumns,
			nullable,
			currentDepth
	);
	//we can use an inner join for the many-to-many
	if ( joinType==JoinType.LEFT_OUTER_JOIN && path.isRoot() ) {
		joinType=JoinType.INNER_JOIN;
	}
	return joinType;
}
 
Example 22
Project: lams   File: CascadeEntityJoinWalker.java   View source code 5 votes vote down vote up
public CascadeEntityJoinWalker(OuterJoinLoadable persister, CascadingAction action, SessionFactoryImplementor factory)
throws MappingException {
	super( persister, factory, LoadQueryInfluencers.NONE );
	this.cascadeAction = action;
	StringBuilder whereCondition = whereString( getAlias(), persister.getIdentifierColumnNames(), 1 )
			//include the discriminator and class-level where, but not filters
			.append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) );

	initAll( whereCondition.toString(), "", LockOptions.READ );
}
 
Example 23
Project: lams   File: HbmBinder.java   View source code 5 votes vote down vote up
public static void bindUnionSubclass(Element node, UnionSubclass unionSubclass,
		Mappings mappings, java.util.Map inheritedMetas) throws MappingException {

	bindClass( node, unionSubclass, mappings, inheritedMetas );
	inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from <subclass>

	Attribute schemaNode = node.attribute( "schema" );
	String schema = schemaNode == null ?
			mappings.getSchemaName() : schemaNode.getValue();

	Attribute catalogNode = node.attribute( "catalog" );
	String catalog = catalogNode == null ?
			mappings.getCatalogName() : catalogNode.getValue();

	Table denormalizedSuperTable = unionSubclass.getSuperclass().getTable();
	Table mytable = mappings.addDenormalizedTable(
			schema,
			catalog,
			getClassTableName(unionSubclass, node, schema, catalog, denormalizedSuperTable, mappings ),
	        unionSubclass.isAbstract() != null && unionSubclass.isAbstract(),
			getSubselect( node ),
			denormalizedSuperTable
		);
	unionSubclass.setTable( mytable );

	if ( LOG.isDebugEnabled() ) {
		LOG.debugf( "Mapping union-subclass: %s -> %s", unionSubclass.getEntityName(), unionSubclass.getTable().getName() );
	}

	createClassProperties( node, unionSubclass, mappings, inheritedMetas );

}
 
Example 24
Project: lams   File: OneToManyPersister.java   View source code 5 votes vote down vote up
/**
 * Create the <tt>OneToManyLoader</tt>
 *
 * @see org.hibernate.loader.collection.OneToManyLoader
 */
@Override
   protected CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers)
		throws MappingException {
	return BatchingCollectionInitializerBuilder.getBuilder( getFactory() )
			.createBatchingOneToManyInitializer( this, batchSize, getFactory(), loadQueryInfluencers );
}
 
Example 25
Project: lams   File: AbstractEntityPersister.java   View source code 5 votes vote down vote up
public final void postInstantiate() throws MappingException {
	doLateInit();

	createLoaders();
	createUniqueKeyLoaders();
	createQueryLoader();

	doPostInstantiate();
}
 
Example 26
Project: lams   File: HbmBinder.java   View source code 5 votes vote down vote up
private static void bindSimpleValueType(Element node, SimpleValue simpleValue, Mappings mappings)
		throws MappingException {
	String typeName = null;

	Properties parameters = new Properties();

	Attribute typeNode = node.attribute( "type" );
       if ( typeNode == null ) {
           typeNode = node.attribute( "id-type" ); // for an any
       }
       else {
           typeName = typeNode.getValue();
       }

	Element typeChild = node.element( "type" );
	if ( typeName == null && typeChild != null ) {
		typeName = typeChild.attribute( "name" ).getValue();
		Iterator typeParameters = typeChild.elementIterator( "param" );

		while ( typeParameters.hasNext() ) {
			Element paramElement = (Element) typeParameters.next();
			parameters.setProperty(
					paramElement.attributeValue( "name" ),
					paramElement.getTextTrim()
				);
		}
	}

	resolveAndBindTypeDef(simpleValue, mappings, typeName, parameters);
}
 
Example 27
Project: lams   File: EntityLoader.java   View source code 5 votes vote down vote up
public EntityLoader(
		OuterJoinLoadable persister,
		String[] uniqueKey,
		Type uniqueKeyType,
		int batchSize,
		LockOptions lockOptions,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	super( persister, uniqueKeyType, factory, loadQueryInfluencers );

	EntityJoinWalker walker = new EntityJoinWalker(
			persister,
			uniqueKey,
			batchSize,
			lockOptions,
			factory,
			loadQueryInfluencers
	);
	initFromWalker( walker );
	this.compositeKeyManyToOneTargetIndices = walker.getCompositeKeyManyToOneTargetIndices();
	postInstantiate();

	batchLoader = batchSize > 1;

	if ( LOG.isDebugEnabled() ) {
		LOG.debugf( "Static select for entity %s [%s:%s]: %s",
				entityName,
				lockOptions.getLockMode(),
				lockOptions.getTimeOut(),
				getSQLString() );
	}
}
 
Example 28
Project: lams   File: Component.java   View source code 5 votes vote down vote up
@Override
public Type getType() throws MappingException {
	// TODO : temporary initial step towards HHH-1907
	final ComponentMetamodel metamodel = new ComponentMetamodel( this );
	final TypeFactory factory = getMappings().getTypeResolver().getTypeFactory();
	return isEmbedded() ? factory.embeddedComponent( metamodel ) : factory.component( metamodel );
}
 
Example 29
Project: lams   File: PropertyInferredData.java   View source code 5 votes vote down vote up
public XClass getClassOrElement() throws MappingException {
	if ( property.isAnnotationPresent( Target.class ) ) {
		return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() );
	}
	else {
		return property.getClassOrElementClass();
	}
}
 
Example 30
Project: lams   File: Helper.java   View source code 5 votes vote down vote up
public static Class classForName(String className, ServiceRegistry serviceRegistry) {
	ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
	try {
		return classLoaderService.classForName( className );
	}
	catch ( ClassLoadingException e ) {
		throw new MappingException( "Could not find class: " + className );
	}
}
 
Example 31
Project: lams   File: Table.java   View source code 5 votes vote down vote up
public UniqueKey addUniqueKey(UniqueKey uniqueKey) {
	UniqueKey current = uniqueKeys.get( uniqueKey.getName() );
	if ( current != null ) {
		throw new MappingException( "UniqueKey " + uniqueKey.getName() + " already exists!" );
	}
	uniqueKeys.put( uniqueKey.getName(), uniqueKey );
	return uniqueKey;
}
 
Example 32
Project: lams   File: HbmBinder.java   View source code 5 votes vote down vote up
public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
		throws MappingException {
	HbmBinder.bindListSecondPass(
			node,
			(List) collection,
			persistentClasses,
			mappings,
			inheritedMetas
		);
}
 
Example 33
Project: lams   File: NameGenerator.java   View source code 5 votes vote down vote up
public static String[][] generateColumnNames(Type[] types, SessionFactoryImplementor f) throws MappingException {
	String[][] columnNames = new String[types.length][];
	for ( int i = 0; i < types.length; i++ ) {
		int span = types[i].getColumnSpan( f );
		columnNames[i] = new String[span];
		for ( int j = 0; j < span; j++ ) {
			columnNames[i][j] = NameGenerator.scalarName( i, j );
		}
	}
	return columnNames;
}
 
Example 34
Project: lams   File: CriteriaQueryTranslator.java   View source code 5 votes vote down vote up
private PropertyMapping getPropertyMapping(String entityName) throws MappingException {
	final CriteriaInfoProvider info = nameCriteriaInfoMap.get( entityName );
	if ( info == null ) {
		throw new HibernateException( "Unknown entity: " + entityName );
	}
	return info.getPropertyMapping();
}
 
Example 35
Project: lams   File: TypeFactory.java   View source code 5 votes vote down vote up
public static void injectParameters(Object type, Properties parameters) {
	if ( ParameterizedType.class.isInstance( type ) ) {
		( (ParameterizedType) type ).setParameterValues(parameters);
	}
	else if ( parameters!=null && !parameters.isEmpty() ) {
		throw new MappingException( "type is not parameterized: " + type.getClass().getName() );
	}
}
 
Example 36
Project: lams   File: SQLQueryReturnProcessor.java   View source code 5 votes vote down vote up
private SQLLoadable getSQLLoadable(String entityName) throws MappingException {
	EntityPersister persister = factory.getEntityPersister( entityName );
	if ( !(persister instanceof SQLLoadable) ) {
		throw new MappingException( "class persister is not SQLLoadable: " + entityName );
	}
	return (SQLLoadable) persister;
}
 
Example 37
Project: lams   File: Any.java   View source code 5 votes vote down vote up
public Type getType() throws MappingException {
	final Type metaType = getMappings().getTypeResolver().heuristicType( metaTypeName );

	return getMappings().getTypeResolver().getTypeFactory().any(
			metaValues == null ? metaType : new MetaType( metaValues, metaType ),
			getMappings().getTypeResolver().heuristicType( identifierTypeName )
	);
}
 
Example 38
Project: lams   File: CustomCollectionType.java   View source code 5 votes vote down vote up
private static UserCollectionType createUserCollectionType(Class userTypeClass) {
	if ( !UserCollectionType.class.isAssignableFrom( userTypeClass ) ) {
		throw new MappingException( "Custom type does not implement UserCollectionType: " + userTypeClass.getName() );
	}

	try {
		return ( UserCollectionType ) userTypeClass.newInstance();
	}
	catch ( InstantiationException ie ) {
		throw new MappingException( "Cannot instantiate custom type: " + userTypeClass.getName() );
	}
	catch ( IllegalAccessException iae ) {
		throw new MappingException( "IllegalAccessException trying to instantiate custom type: " + userTypeClass.getName() );
	}
}
 
Example 39
Project: lams   File: Component.java   View source code 5 votes vote down vote up
public Class getComponentClass() throws MappingException {
	try {
		return ReflectHelper.classForName(componentClassName);
	}
	catch (ClassNotFoundException cnfe) {
		throw new MappingException("component class not found: " + componentClassName, cnfe);
	}
}
 
Example 40
Project: lams   File: Configuration.java   View source code 5 votes vote down vote up
/**
 * Read mappings as a application resource (i.e. classpath lookup).
 *
 * @param resourceName The resource name
 * @param classLoader The class loader to use.
 * @return this (for method chaining purposes)
 * @throws MappingException Indicates problems locating the resource or
 * processing the contained mapping document.
 */
public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
	LOG.readingMappingsFromResource( resourceName );
	InputStream resourceInputStream = classLoader.getResourceAsStream( resourceName );
	if ( resourceInputStream == null ) {
		throw new MappingNotFoundException( "resource", resourceName );
	}
	add( resourceInputStream, "resource", resourceName );
	return this;
}