Package org.hibernate.metamodel.source

Examples of org.hibernate.metamodel.source.MappingException


      }
      else if ( XMLSqlQueryElement.class.isInstance( queryOrSqlQuery ) ) {
//        bindNamedSQLQuery( element, null, mappings );
      }
      else {
        throw new MappingException(
            "unknown type of query: " +
                queryOrSqlQuery.getClass().getName(), jaxbRoot.getOrigin()
        );
      }
    }
View Full Code Here


    }
  }

  private void checkQueryName(String name) {
    if ( namedQueryMap.containsKey( name ) || namedNativeQueryMap.containsKey( name ) ) {
      throw new MappingException( "Duplicated query mapping " + name, null );
    }
  }
View Full Code Here

  private void put(XMLSqlResultSetMapping mapping) {
    if ( mapping != null ) {
      Object old = sqlResultSetMappingMap.put( mapping.getName(), mapping );
      if ( old != null ) {
        throw new MappingException( "Duplicated SQL result set mapping " +  mapping.getName(), null );
      }
    }
  }
View Full Code Here

        catch ( Exception ignore ) {
        }
      }
    }
    catch ( XMLStreamException e ) {
      throw new MappingException( "Unable to create stax reader", e, origin );
    }
  }
View Full Code Here

    final String optimisticLockModeString = Helper.getStringValue( entityElement().getOptimisticLock(), "version" );
    try {
      return OptimisticLockStyle.valueOf( optimisticLockModeString.toUpperCase() );
    }
    catch (Exception e) {
      throw new MappingException(
          "Unknown optimistic-lock value : " + optimisticLockModeString,
          sourceMappingDocument().getOrigin()
      );
    }
  }
View Full Code Here

    }
    else if ( "false".equals( lazySelection ) ) {
      return FetchTiming.IMMEDIATE;
    }

    throw new MappingException(
        String.format(
            "Unexpected lazy selection [%s] on '%s'",
            lazySelection,
            manyToOneElement.getName()
        ),
View Full Code Here

    }
  }

  private void checkQueryName(String name) {
    if ( namedQueryMap.containsKey( name ) || namedNativeQueryMap.containsKey( name ) ) {
      throw new MappingException( "Duplicated query mapping " + name, null );
    }
  }
View Full Code Here

  private void put(JaxbSqlResultSetMapping mapping) {
    if ( mapping != null ) {
      Object old = sqlResultSetMappingMap.put( mapping.getName(), mapping );
      if ( old != null ) {
        throw new MappingException( "Duplicated SQL result set mapping " +  mapping.getName(), null );
      }
    }
  }
View Full Code Here

        catch ( Exception ignore ) {
        }
      }
    }
    catch ( XMLStreamException e ) {
      throw new MappingException( "Unable to create stax reader", e, origin );
    }
  }
View Full Code Here

        staxEventReader.nextEvent();
        event = staxEventReader.peek();
      }
    }
    catch ( Exception e ) {
      throw new MappingException( "Error accessing stax stream", e, origin );
    }

    if ( event == null ) {
      throw new MappingException( "Could not locate root element", origin );
    }

    final Schema validationSchema;
    final Class jaxbTarget;

    final String elementName = event.asStartElement().getName().getLocalPart();

    if ( "entity-mappings".equals( elementName ) ) {
      final Attribute attribute = event.asStartElement().getAttributeByName( ORM_VERSION_ATTRIBUTE_QNAME );
      final String explicitVersion = attribute == null ? null : attribute.getValue();
      validationSchema = resolveSupportedOrmXsd( explicitVersion );
      jaxbTarget = JaxbEntityMappings.class;
    }
    else {
      validationSchema = hbmSchema();
      jaxbTarget = JaxbHibernateMapping.class;
    }

    final Object target;
    final ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
    try {
      JAXBContext jaxbContext = JAXBContext.newInstance( jaxbTarget );
      Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
      unmarshaller.setSchema( validationSchema );
      unmarshaller.setEventHandler( handler );
      target = unmarshaller.unmarshal( staxEventReader );
    }

    catch ( JAXBException e ) {
      StringBuilder builder = new StringBuilder();
      builder.append( "Unable to perform unmarshalling at line number " );
      builder.append( handler.getLineNumber() );
      builder.append( " and column " );
      builder.append( handler.getColumnNumber() );
      builder.append( ". Message: " );
      builder.append( handler.getMessage() );
      throw new MappingException( builder.toString(), e, origin );
    }

    return new JaxbRoot( target, origin );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.metamodel.source.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.