Package org.hibernate

Examples of org.hibernate.MappingException


    if ( precedence == null ) {
      precedence = DEFAULT_PRECEDENCE;
    }
    StringTokenizer precedences = new StringTokenizer( precedence, ",; ", false );
    if ( !precedences.hasMoreElements() ) {
      throw new MappingException( ARTEFACT + " cannot be empty: " + precedence );
    }
    while ( precedences.hasMoreElements() ) {
      String artifact = ( String ) precedences.nextElement();
      removeConflictedArtifact( artifact );
      processArtifactsOfType( artifact );
View Full Code Here


      Class loadedClass;
      try {
        loadedClass = ReflectHelper.classForName( clazz.getValue() );
      }
      catch ( ClassNotFoundException cnf ) {
        throw new MappingException(
            "Unable to load class declared as <mapping class=\"" + clazz.getValue() + "\"/> in the configuration:",
            cnf
        );
      }
      catch ( NoClassDefFoundError ncdf ) {
        throw new MappingException(
            "Unable to load class declared as <mapping class=\"" + clazz.getValue() + "\"/> in the configuration:",
            ncdf
        );
      }

      addAnnotatedClass( loadedClass );
    }
    else {
      throw new MappingException( "<mapping> element in configuration specifies no attributes" );
    }
  }
View Full Code Here

        //the document is syntactically incorrect

        //DOM4J sometimes wraps the SAXParseException wo much interest
        final Throwable throwable = e.getCause();
        if ( e.getCause() == null || !( throwable instanceof SAXParseException ) ) {
          throw new MappingException( "Could not parse JPA mapping document", e );
        }
        errors.add( (SAXParseException) throwable );
      }

      boolean isV1Schema = false;
      if ( errors.size() != 0 ) {
        SAXParseException exception = errors.get( 0 );
        final String errorMessage = exception.getMessage();
        //does the error look like a schema mismatch?
        isV1Schema = doc != null
            && errorMessage.contains("1.0")
            && errorMessage.contains("2.0")
            && errorMessage.contains("version");
      }
      if (isV1Schema) {
        //reparse with v1
        errors.clear();
        setValidationFor( saxReader, "orm_1_0.xsd" );
        try {
          //too bad we have to reparse to validate again :(
          saxReader.read( new StringReader( doc.asXML() ) );
        }
        catch ( DocumentException e ) {
          //oops asXML fails even if the core doc parses initially
          throw new AssertionFailure("Error in DOM4J leads to a bug in Hibernate", e);
        }

      }
      if ( errors.size() != 0 ) {
        //report errors in exception
        StringBuilder errorMessage = new StringBuilder( );
        for (SAXParseException error : errors) {
          errorMessage.append("Error parsing XML (line")
                .append(error.getLineNumber())
                .append(" : column ")
                .append(error.getColumnNumber())
                .append("): ")
                .append(error.getMessage())
                .append("\n");
        }
        throw new MappingException( "Invalid ORM mapping file.\n" + errorMessage.toString() );
      }
      add( doc );
      return this;
    }
    finally {
View Full Code Here

    private String getLogicalTableName(String schema, String catalog, String physicalName) throws MappingException {
      String key = buildTableNameKey( schema, catalog, physicalName );
      TableDescription descriptor = (TableDescription) tableNameBinding.get( key );
      if (descriptor == null) {
        throw new MappingException( "Unable to find physical table: " + physicalName);
      }
      return descriptor.logicalName;
    }
View Full Code Here

          currentTable = null;
        }
      } while ( finalName == null && currentTable != null );

      if ( finalName == null ) {
        throw new MappingException(
            "Unable to find column with logical name " + logicalName + " in table " + table.getName()
        );
      }
      return finalName;
    }
View Full Code Here

          currentTable = null;
        }
      }
      while ( logical == null && currentTable != null && description != null );
      if ( logical == null ) {
        throw new MappingException(
            "Unable to find logical column name from physical name "
                + physicalName + " in table " + table.getName()
        );
      }
      return logical;
View Full Code Here

        String typeFromXML = HbmBinder.getTypeFromXML( returnElem );
        Type type = null;
        if(typeFromXML!=null) {
          type = mappings.getTypeResolver().heuristicType( typeFromXML );
          if ( type == null ) {
            throw new MappingException( "could not determine type " + type );
          }
        }
        definition.addQueryReturn( new NativeSQLQueryScalarReturn( column, type ) );
      }
      else if ( "return".equals( name ) ) {
View Full Code Here

      alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key.
    }

    String entityName = HbmBinder.getEntityName(returnElem, mappings);
    if(entityName==null) {
      throw new MappingException( "<return alias='" + alias + "'> must specify either a class or entity-name");
    }
    LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );

    PersistentClass pc = mappings.getClass( entityName );
    java.util.Map propertyResults = bindPropertyResults(alias, returnElem, pc, mappings );
View Full Code Here

    String alias = returnElem.attributeValue( "alias" );
    String roleAttribute = returnElem.attributeValue( "property" );
    LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
    int dot = roleAttribute.lastIndexOf( '.' );
    if ( dot == -1 ) {
      throw new MappingException(
          "Role attribute for sql query return [alias=" + alias +
          "] not formatted correctly {owningAlias.propertyName}"
        );
    }
    String roleOwnerAlias = roleAttribute.substring( 0, dot );
View Full Code Here

    String alias = returnElem.attributeValue( "alias" );
    String collectionAttribute = returnElem.attributeValue( "role" );
    LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
    int dot = collectionAttribute.lastIndexOf( '.' );
    if ( dot == -1 ) {
      throw new MappingException(
          "Collection attribute for sql query return [alias=" + alias +
          "] not formatted correctly {OwnerClassName.propertyName}"
        );
    }
    String ownerClassName = HbmBinder.getClassName( collectionAttribute.substring( 0, dot ), mappings );
View Full Code Here

TOP

Related Classes of org.hibernate.MappingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.