Java 类org.hibernate.MappingException 实例源码

项目:lams    文件:StatefulPersistenceContext.java   
@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;
    }
}
项目:lams    文件:AbstractQueryImpl.java   
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;
    }
}
项目:lams    文件:SerializableToBlobType.java   
@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 );
        }
    }
}
项目:lams    文件:HbmBinder.java   
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 ) );

}
项目:lams    文件:NamedProcedureCallDefinition.java   
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
                )
        );
    }
}
项目:lams    文件:PersistentClass.java   
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);
}
项目:lams    文件:PersistentClass.java   
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\")"
                    );
            }
        }
    }
}
项目:lams    文件:HbmBinder.java   
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 );
    }
}
项目:lams    文件:EntityClass.java   
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;
}
项目:lams    文件:OneToManyJoinWalker.java   
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);
}
项目:lams    文件:AbstractPropertyMapping.java   
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);
    }
}
项目:lams    文件:JoinWalker.java   
/**
 * 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;
        }
    }
}
项目:lams    文件:PropertyInferredData.java   
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;
}
项目:lams    文件:AbstractEntityPersister.java   
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() );
}
项目:lams    文件:SimpleValue.java   
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 );
    }
}
项目:lams    文件:LegacyBatchingCollectionInitializerBuilder.java   
@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 );
}
项目:lams    文件:EntityLoader.java   
public EntityLoader(
        OuterJoinLoadable persister,
        LockMode lockMode,
        SessionFactoryImplementor factory,
        LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
    this( persister, 1, lockMode, factory, loadQueryInfluencers );
}
项目:lams    文件:IdentifierCollection.java   
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()
        );
    }
}
项目:lams    文件:QueryTranslatorImpl.java   
/**
 * 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;

}
项目:lams    文件:BasicCollectionJoinWalker.java   
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;
}
项目:lams    文件:CascadeEntityJoinWalker.java   
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 );
}
项目:lams    文件:HbmBinder.java   
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 );

}
项目:lams    文件:OneToManyPersister.java   
/**
 * 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 );
}
项目:lams    文件:AbstractEntityPersister.java   
public final void postInstantiate() throws MappingException {
    doLateInit();

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

    doPostInstantiate();
}
项目:lams    文件:HbmBinder.java   
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);
}
项目:lams    文件:EntityLoader.java   
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() );
    }
}
项目:lams    文件:Component.java   
@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 );
}
项目:lams    文件:PropertyInferredData.java   
public XClass getClassOrElement() throws MappingException {
    if ( property.isAnnotationPresent( Target.class ) ) {
        return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() );
    }
    else {
        return property.getClassOrElementClass();
    }
}
项目:lams    文件:Helper.java   
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 );
    }
}
项目:lams    文件:Table.java   
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;
}
项目:lams    文件:HbmBinder.java   
public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
        throws MappingException {
    HbmBinder.bindListSecondPass(
            node,
            (List) collection,
            persistentClasses,
            mappings,
            inheritedMetas
        );
}
项目:lams    文件:NameGenerator.java   
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;
}
项目:lams    文件:CriteriaQueryTranslator.java   
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();
}
项目:lams    文件:TypeFactory.java   
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() );
    }
}
项目:lams    文件:SQLQueryReturnProcessor.java   
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;
}
项目:lams    文件:Any.java   
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 )
    );
}
项目:lams    文件:CustomCollectionType.java   
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() );
    }
}
项目:lams    文件:Component.java   
public Class getComponentClass() throws MappingException {
    try {
        return ReflectHelper.classForName(componentClassName);
    }
    catch (ClassNotFoundException cnfe) {
        throw new MappingException("component class not found: " + componentClassName, cnfe);
    }
}
项目:lams    文件:Configuration.java   
/**
 * 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;
}