Examples of MappingException


Examples of org.dozer.MappingException

  public static void throwMappingException(String msg) throws MappingException {
    throw new MappingException(msg);
  }

  public static void throwMappingException(String msg, Throwable cause) throws MappingException {
    throw new MappingException(msg, cause);
  }
View Full Code Here

Examples of org.exolab.castor.mapping.MappingException

     * @throws MappingException
     *             in case that the name is null or the Class can not be loaded
     */
    public void addClass(final String name, final boolean deep) throws MappingException {
        if (name == null) {
            throw new MappingException("Cannot introspect a null class.");
        }

        try {
            addClass(Class.forName(name), deep);
        } catch (ClassNotFoundException except) {
            throw new MappingException(except);
        }
    } // -- addClass
View Full Code Here

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

Examples of org.hibernate.MappingException

      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

Examples of org.hibernate.MappingException

        //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

Examples of org.hibernate.MappingException

    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

Examples of org.hibernate.MappingException

          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

Examples of org.hibernate.MappingException

          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

Examples of org.hibernate.MappingException

        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

Examples of org.hibernate.MappingException

      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
TOP
Copyright © 2018 www.massapi.com. 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.